Skip to content

Commit bbe1cd1

Browse files
crdantclaude
andcommitted
fix: remove duplicate Test_buildInstallConfig_License function
Removes the duplicate Test_buildInstallConfig_License test from install_test.go which was causing a vet error for function redeclaration. The canonical version of this test remains in install_config_test.go (line 538) and has been properly updated to use GetLicenseID() and GetAppSlug() getter methods instead of direct Spec field access. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7ffacf7 commit bbe1cd1

File tree

1 file changed

+2
-123
lines changed

1 file changed

+2
-123
lines changed

cmd/installer/cli/install_test.go

Lines changed: 2 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"net/http/httptest"
99
"os"
10+
"path/filepath"
1011
"testing"
1112

1213
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
@@ -595,7 +596,7 @@ versionLabel: testversion
595596
req.NoError(err)
596597
}
597598

598-
_, err = verifyLicense(license)
599+
err = verifyLicense(license)
599600

600601
if tt.wantErr != "" {
601602
req.EqualError(err, tt.wantErr)
@@ -895,125 +896,3 @@ func stringPtr(s string) *string {
895896
return &s
896897
}
897898

898-
func Test_buildInstallConfig_License(t *testing.T) {
899-
// Create a temporary directory for test license files
900-
tmpdir := t.TempDir()
901-
902-
// Valid test license data (YAML format for a kotsv1beta1.License)
903-
validLicenseData := `apiVersion: kots.io/v1beta1
904-
kind: License
905-
metadata:
906-
name: test-license
907-
spec:
908-
licenseID: test-license-id
909-
appSlug: test-app
910-
channelID: test-channel-id
911-
channelName: Test Channel
912-
customerName: Test Customer
913-
endpoint: https://replicated.app
914-
entitlements:
915-
expires_at:
916-
title: Expiration
917-
value: "2030-01-01T00:00:00Z"
918-
valueType: String
919-
isEmbeddedClusterDownloadEnabled: true`
920-
921-
// Create a valid license file
922-
validLicensePath := filepath.Join(tmpdir, "valid-license.yaml")
923-
err := os.WriteFile(validLicensePath, []byte(validLicenseData), 0644)
924-
require.NoError(t, err)
925-
926-
tests := []struct {
927-
name string
928-
licenseFile string
929-
wantErr string
930-
expectLicense bool
931-
}{
932-
{
933-
name: "no license file provided",
934-
licenseFile: "",
935-
wantErr: "",
936-
expectLicense: false,
937-
},
938-
{
939-
name: "license file does not exist",
940-
licenseFile: filepath.Join(tmpdir, "nonexistent.yaml"),
941-
wantErr: "failed to read license file",
942-
expectLicense: false,
943-
},
944-
{
945-
name: "invalid license file - not YAML",
946-
licenseFile: func() string {
947-
invalidPath := filepath.Join(tmpdir, "invalid-license.txt")
948-
os.WriteFile(invalidPath, []byte("this is not a valid license file"), 0644)
949-
return invalidPath
950-
}(),
951-
wantErr: "failed to parse license file",
952-
expectLicense: false,
953-
},
954-
{
955-
name: "invalid license file - wrong kind",
956-
licenseFile: func() string {
957-
wrongKindPath := filepath.Join(tmpdir, "wrong-kind.yaml")
958-
wrongKindData := `apiVersion: v1
959-
kind: ConfigMap
960-
metadata:
961-
name: not-a-license`
962-
os.WriteFile(wrongKindPath, []byte(wrongKindData), 0644)
963-
return wrongKindPath
964-
}(),
965-
wantErr: "failed to parse license file",
966-
expectLicense: false,
967-
},
968-
{
969-
name: "corrupt license file - invalid YAML",
970-
licenseFile: func() string {
971-
corruptPath := filepath.Join(tmpdir, "corrupt-license.yaml")
972-
corruptData := `apiVersion: kots.io/v1beta1
973-
kind: License
974-
metadata:
975-
name: test
976-
spec:
977-
this is not valid yaml: [[[`
978-
os.WriteFile(corruptPath, []byte(corruptData), 0644)
979-
return corruptPath
980-
}(),
981-
wantErr: "failed to parse license file",
982-
expectLicense: false,
983-
},
984-
{
985-
name: "valid license file",
986-
licenseFile: validLicensePath,
987-
wantErr: "",
988-
expectLicense: true,
989-
},
990-
}
991-
992-
for _, tt := range tests {
993-
t.Run(tt.name, func(t *testing.T) {
994-
flags := &installFlags{
995-
licenseFile: tt.licenseFile,
996-
}
997-
998-
installCfg, err := buildInstallConfig(flags)
999-
1000-
if tt.wantErr != "" {
1001-
require.Error(t, err)
1002-
assert.Contains(t, err.Error(), tt.wantErr)
1003-
} else {
1004-
require.NoError(t, err)
1005-
1006-
if tt.expectLicense {
1007-
assert.NotEmpty(t, installCfg.licenseBytes, "License bytes should be populated")
1008-
assert.NotEmpty(t, installCfg.license.GetLicenseID(), "License should be parsed")
1009-
assert.Equal(t, "test-license-id", installCfg.license.GetLicenseID())
1010-
assert.Equal(t, "test-app", installCfg.license.GetAppSlug())
1011-
} else {
1012-
assert.Empty(t, installCfg.licenseBytes, "License bytes should be empty")
1013-
assert.Nil(t, installCfg.license, "License should be nil")
1014-
}
1015-
}
1016-
})
1017-
}
1018-
}
1019-

0 commit comments

Comments
 (0)