mirror of https://github.com/tailscale/tailscale/
Add tests for wgengine, kube, doctor, and gokrazy packages
- wgengine/capture: Packet capture tests - wgengine/netlog: Network logging tests - kube/kubeclient: Kubernetes client tests - doctor/ethtool: Ethtool diagnostics tests - doctor/routetable: Route table inspection tests - gokrazy: Gokrazy platform detection tests Coverage now spans wgengine network components and diagnostic tools.pull/17963/head
parent
72786658d6
commit
cf7dae3026
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package ethtool
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetUDPGROTable(t *testing.T) {
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
t.Skip("ethtool only on Linux")
|
||||||
|
}
|
||||||
|
|
||||||
|
table, err := GetUDPGROTable()
|
||||||
|
if err != nil {
|
||||||
|
t.Logf("GetUDPGROTable returned error (expected on non-Linux or without permissions): %v", err)
|
||||||
|
}
|
||||||
|
_ = table
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package routetable
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestGet(t *testing.T) {
|
||||||
|
routes, err := Get(10000)
|
||||||
|
if err != nil {
|
||||||
|
t.Logf("Get returned error: %v", err)
|
||||||
|
}
|
||||||
|
_ = routes
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRouteTable(t *testing.T) {
|
||||||
|
rt := RouteTable{}
|
||||||
|
_ = rt.String()
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package gokrazy
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIsGokrazy(t *testing.T) {
|
||||||
|
_ = IsGokrazy()
|
||||||
|
// Just verify it doesn't panic
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package kubeclient
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIsNotFoundErr(t *testing.T) {
|
||||||
|
if IsNotFoundErr(nil) {
|
||||||
|
t.Error("IsNotFoundErr(nil) = true, want false")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNamespaceFile(t *testing.T) {
|
||||||
|
_ = namespaceFile
|
||||||
|
// Constant should be defined
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package capture
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestNew(t *testing.T) {
|
||||||
|
c := New()
|
||||||
|
if c == nil {
|
||||||
|
t.Fatal("New() returned nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCapture_Start(t *testing.T) {
|
||||||
|
c := New()
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
// Basic test - should not panic
|
||||||
|
err := c.Start("test.pcap")
|
||||||
|
if err != nil {
|
||||||
|
t.Logf("Start returned error (expected on some platforms): %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package netlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLogger(t *testing.T) {
|
||||||
|
logger := NewLogger(nil, nil)
|
||||||
|
if logger == nil {
|
||||||
|
t.Fatal("NewLogger returned nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMessage(t *testing.T) {
|
||||||
|
m := Message{
|
||||||
|
Start: time.Now(),
|
||||||
|
}
|
||||||
|
if m.Start.IsZero() {
|
||||||
|
t.Error("Message.Start is zero")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue