2022-02-03 18:35:54 +01:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
2022-05-25 23:25:02 +02:00
|
|
|
"context"
|
2022-02-03 18:35:54 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-05-25 23:25:02 +02:00
|
|
|
"google.golang.org/grpc/metadata"
|
2022-02-03 18:35:54 +01:00
|
|
|
)
|
|
|
|
|
2022-05-25 23:25:02 +02:00
|
|
|
func Test_LocalWTVersion(t *testing.T) {
|
|
|
|
got := GetInfo(context.TODO())
|
2022-02-03 18:35:54 +01:00
|
|
|
want := "development"
|
2025-02-05 16:49:41 +01:00
|
|
|
assert.Equal(t, want, got.NetbirdVersion)
|
2022-02-03 18:35:54 +01:00
|
|
|
}
|
2022-05-25 23:25:02 +02:00
|
|
|
|
|
|
|
func Test_UIVersion(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
want := "netbird-desktop-ui/development"
|
|
|
|
ctx = metadata.NewOutgoingContext(ctx, map[string][]string{
|
|
|
|
"user-agent": {want},
|
|
|
|
})
|
|
|
|
|
|
|
|
got := GetInfo(ctx)
|
|
|
|
assert.Equal(t, want, got.UIVersion)
|
|
|
|
}
|
2023-04-20 16:00:22 +02:00
|
|
|
|
|
|
|
func Test_CustomHostname(t *testing.T) {
|
|
|
|
// nolint
|
|
|
|
ctx := context.WithValue(context.Background(), DeviceNameCtxKey, "custom-host")
|
|
|
|
want := "custom-host"
|
|
|
|
|
|
|
|
got := GetInfo(ctx)
|
|
|
|
assert.Equal(t, want, got.Hostname)
|
|
|
|
}
|
2024-02-20 11:53:11 +01:00
|
|
|
|
|
|
|
func Test_NetAddresses(t *testing.T) {
|
|
|
|
addr, err := networkAddresses()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("failed to discover network addresses: %s", err)
|
|
|
|
}
|
|
|
|
if len(addr) == 0 {
|
|
|
|
t.Errorf("no network addresses found")
|
|
|
|
}
|
|
|
|
}
|