mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* WTF-657 Add spec coverage for cfg/common_settings.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for cfg/position_validation.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for cfg/validations.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for checklist/checklist.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for checklist/checklist_item.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for utils/conversions.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Get rid of utils.Home() function Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for utils/homedir.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for utils/text.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Clean up utils/utils.go Signed-off-by: Chris Cummer <chriscummer@me.com>
61 lines
1.0 KiB
Go
61 lines
1.0 KiB
Go
package kubernetes
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_generateTitle(t *testing.T) {
|
|
type fields struct {
|
|
title string
|
|
namespaces []string
|
|
}
|
|
|
|
testCases := []struct {
|
|
name string
|
|
fields fields
|
|
want string
|
|
}{
|
|
{
|
|
name: "No Namespaces",
|
|
fields: fields{
|
|
namespaces: []string{},
|
|
},
|
|
want: "Kube",
|
|
},
|
|
{
|
|
name: "One Namespace",
|
|
fields: fields{
|
|
namespaces: []string{"some-namespace"},
|
|
},
|
|
want: "Kube - Namespace: some-namespace",
|
|
},
|
|
{
|
|
name: "Multiple Namespaces",
|
|
fields: fields{
|
|
namespaces: []string{"ns1", "ns2"},
|
|
},
|
|
want: `Kube - Namespaces: ["ns1" "ns2"]`,
|
|
},
|
|
{
|
|
name: "Explicit Title Set",
|
|
fields: fields{
|
|
namespaces: []string{},
|
|
title: "Test Explicit Title",
|
|
},
|
|
want: "Test Explicit Title",
|
|
},
|
|
}
|
|
|
|
for _, tt := range testCases {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
widget := &Widget{
|
|
title: tt.fields.title,
|
|
namespaces: tt.fields.namespaces,
|
|
}
|
|
assert.Equal(t, tt.want, widget.generateTitle())
|
|
})
|
|
}
|
|
}
|