package logs_test import ( "testing" "git.netflux.io/rob/kubectl-persistent-logger/logs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestParseKind(t *testing.T) { testCases := []struct { input string wantOut string wantErr string }{ { input: "deploy", wantOut: "deployments", }, { input: "deployment", wantOut: "deployments", }, { input: "deployments", wantOut: "deployments", }, { input: "sts", wantOut: "statefulsets", }, { input: "statefulset", wantOut: "statefulsets", }, { input: "statefulsets", wantOut: "statefulsets", }, { input: "rs", wantOut: "replicasets", }, { input: "replicaset", wantOut: "replicasets", }, { input: "replicasets", wantOut: "replicasets", }, { input: "foo", wantErr: `unsupported resource: "foo". Supported resources are [deployment, statefulset, replicaset]`, }, } for _, tc := range testCases { t.Run(tc.input, func(t *testing.T) { result, err := logs.ParseType(tc.input) if tc.wantErr != "" { require.EqualError(t, err, tc.wantErr) } assert.Equal(t, tc.wantOut, result) }) } }