40 lines
678 B
Go
40 lines
678 B
Go
package codeserver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"zlh-agent/internal/state"
|
|
)
|
|
|
|
func TestRequested(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
cfg state.Config
|
|
want bool
|
|
}{
|
|
{
|
|
name: "enable flag",
|
|
cfg: state.Config{EnableCodeServer: true},
|
|
want: true,
|
|
},
|
|
{
|
|
name: "addon case insensitive",
|
|
cfg: state.Config{Addons: []string{"CodeServer"}},
|
|
want: true,
|
|
},
|
|
{
|
|
name: "not requested",
|
|
cfg: state.Config{Addons: []string{"other"}},
|
|
want: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := Requested(tt.cfg); got != tt.want {
|
|
t.Fatalf("Requested() = %t, want %t", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|