rename to toughswitch

This commit is contained in:
2026-01-05 15:47:43 -05:00
parent 38eb2cc352
commit 438d422b53
8 changed files with 31 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
package edgeos
package toughswitch
import (
"context"

View File

@@ -1,10 +1,10 @@
/*
Package edgeos provides a client for interacting with Ubiquiti EdgeOS devices
Package toughswitch provides a client for interacting with Ubiquiti toughswitch devices
via their REST API. It supports authentication, token management, and
retrieval of system, interface, VLAN, and discovery information from
one or more devices.
*/
package edgeos
package toughswitch
import (
"bytes"
@@ -19,7 +19,7 @@ import (
"sync"
)
// Client handles communication with EdgeOS devices.
// Client handles communication with toughswitch devices.
type Client struct {
mu sync.RWMutex
devices map[string]*deviceClient

View File

@@ -1,4 +1,4 @@
package edgeos
package toughswitch
import (
"bytes"
@@ -34,11 +34,9 @@ func TestClient_ThreadSafety(t *testing.T) {
start := make(chan struct{})
// Writer: Adds and deletes hosts
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
<-start
for i := 0; i < 100; i++ {
for i := range 100 {
host := fmt.Sprintf("host-%d", i)
cfg := &Config{
Host: host,
@@ -54,20 +52,18 @@ func TestClient_ThreadSafety(t *testing.T) {
t.Logf("Del error: %v", err)
}
}
}()
})
// Reader: Iterates hosts
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
<-start
for i := 0; i < 10; i++ {
for range 10 {
// GetAllInterfaces iterates keys.
// With mock transport, this will succeed (returning empty structs)
// checking for race conditions.
_, _ = client.GetAllInterfaces(ctx)
}
}()
})
close(start)
wg.Wait()
@@ -106,4 +102,4 @@ func TestClient_AddDel(t *testing.T) {
if err := client.Del("test-host"); err == nil {
t.Fatal("Expected error deleting non-existent host, got nil")
}
}
}

View File

@@ -1,11 +1,10 @@
package edgeos
package toughswitch
import (
"net/http"
"time"
)
// Config represents the configuration for an EdgeOS device.
type Config struct {
Host string
Scheme string
@@ -13,6 +12,6 @@ type Config struct {
Username string
Password string
Timeout time.Duration
// Transport allows customizing the http transport (useful for testing)
// Transport allows customizing the http transport (useful for testing or client middleware)
Transport http.RoundTripper
}

View File

@@ -1,4 +1,4 @@
package edgeos
package toughswitch
// LoginResponse represents the response from the login endpoint.
type LoginResponse struct {