-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michael Sverdlov <[email protected]>
- Loading branch information
1 parent
e8566f1
commit 3a1bcf0
Showing
3 changed files
with
80 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package project | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestFromString(t *testing.T) { | ||
// Test valid conversions | ||
tests := []struct { | ||
input string | ||
expected ProjectType | ||
}{ | ||
{"go", Go}, | ||
{"pip", Pip}, | ||
{"npm", Npm}, | ||
{"pnpm", Pnpm}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.input, func(t *testing.T) { | ||
result := FromString(test.input) | ||
assert.Equal(t, test.expected, result, "For input %s, expected %v but got %v", test.input, test.expected, result) | ||
}) | ||
} | ||
|
||
// Test invalid conversion | ||
result := FromString("InvalidProject") | ||
assert.Equal(t, ProjectType(-1), result, "Expected -1 for invalid project type") | ||
} |