Skip to content

Commit bee4d60

Browse files
authored
add cargo as const in project config (#1583)
1 parent b898f36 commit bee4d60

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

common/project/projectconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
Ruby
5050
Conan
5151
UV
52+
Cargo
5253
Apt
5354
Apk
5455
)
@@ -83,6 +84,7 @@ var ProjectTypes = []string{
8384
"ruby",
8485
"conan",
8586
"uv",
87+
"cargo",
8688
"apt",
8789
"apk",
8890
}

common/project/projectconfig_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestFromString(t *testing.T) {
1919
{"ruby", Ruby},
2020
{"conan", Conan},
2121
{"uv", UV},
22+
{"cargo", Cargo},
2223
}
2324

2425
for _, testCase := range testCases {
@@ -32,3 +33,10 @@ func TestFromString(t *testing.T) {
3233
result := FromString("InvalidProject")
3334
assert.Equal(t, ProjectType(-1), result)
3435
}
36+
37+
// TestCargoStringRoundTrip guards the enum/slice alignment: Cargo must stringify to "cargo"
38+
// and round-trip through FromString. A misaligned append would shift indices and break this.
39+
func TestCargoStringRoundTrip(t *testing.T) {
40+
assert.Equal(t, "cargo", Cargo.String())
41+
assert.Equal(t, Cargo, FromString(Cargo.String()))
42+
}

0 commit comments

Comments
 (0)