Skip to content

Commit 0260c45

Browse files
authored
Adding test cases / cleaning up unused fields (#8559)
1 parent c1be040 commit 0260c45

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

internal/pkg/agent/application/upgrade/artifact/artifact_test.go

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,36 @@ func TestGetArtifactName(t *testing.T) {
1717
require.NoError(t, err)
1818

1919
tests := map[string]struct {
20-
a Artifact
21-
version agtversion.ParsedSemVer
22-
operatingSystem string
23-
arch string
24-
expectedName string
25-
expectedErr string
20+
a Artifact
21+
version agtversion.ParsedSemVer
22+
arch string
23+
expectedName string
2624
}{
27-
"no_fips": {
28-
a: Artifact{Cmd: "elastic-agent"},
29-
version: *version,
30-
operatingSystem: "linux",
31-
arch: "arm64",
32-
expectedName: "elastic-agent-9.1.0-linux-arm64.tar.gz",
25+
"no_fips_arm64": {
26+
a: Artifact{Cmd: "elastic-agent"},
27+
version: *version,
28+
arch: "arm64",
29+
expectedName: "elastic-agent-9.1.0-linux-arm64.tar.gz",
3330
},
34-
"fips": {
35-
a: Artifact{Cmd: "elastic-agent-fips"},
36-
version: *version,
37-
operatingSystem: "linux",
38-
arch: "arm64",
39-
expectedName: "elastic-agent-fips-9.1.0-linux-arm64.tar.gz",
31+
"fips_x86": {
32+
a: Artifact{Cmd: "elastic-agent-fips"},
33+
version: *version,
34+
arch: "32",
35+
expectedName: "elastic-agent-fips-9.1.0-linux-x86.tar.gz",
36+
},
37+
"fips_x86_64": {
38+
a: Artifact{Cmd: "elastic-agent-fips"},
39+
version: *version,
40+
arch: "64",
41+
expectedName: "elastic-agent-fips-9.1.0-linux-x86_64.tar.gz",
4042
},
4143
}
4244

4345
for name, test := range tests {
4446
t.Run(name, func(t *testing.T) {
45-
artifactName, err := GetArtifactName(test.a, test.version, test.operatingSystem, test.arch)
46-
if test.expectedErr == "" {
47-
require.NoError(t, err)
48-
require.Equal(t, test.expectedName, artifactName)
49-
} else {
50-
require.Empty(t, artifactName)
51-
require.Equal(t, test.expectedErr, err.Error())
52-
}
47+
artifactName, err := GetArtifactName(test.a, test.version, "linux", test.arch)
48+
require.NoError(t, err)
49+
require.Equal(t, test.expectedName, artifactName)
5350
})
5451
}
5552

0 commit comments

Comments
 (0)