Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed:Compilation errors in choas_hub/handler tests #4113

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DefaultPath = "/tmp/"
func GetChartsPath(chartsInput model.CloningInput, projectID string, isDefault bool) string {
var repoPath string
if isDefault {
repoPath = DefaultPath + "/default/" + chartsInput.Name + "/faults/"
repoPath = DefaultPath + "default/" + chartsInput.Name + "/faults/"
} else {
repoPath = DefaultPath + projectID + "/" + chartsInput.Name + "/faults/"
}
Expand Down
22 changes: 18 additions & 4 deletions chaoscenter/graphql/server/pkg/chaoshub/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,22 @@ func TestGetChartsPath(t *testing.T) {
Name: "test",
}
// when
path := handler.GetChartsPath(chartsInput, projectID)
path := handler.GetChartsPath(chartsInput, projectID, true)
// then
assert.Equal(t, "/tmp/version/test/test/charts/", path)
assert.Equal(t, "/tmp/default/test/faults/", path)
}

func TestGetChartsPathFalse(t *testing.T) {
// given
projectID := "test"

chartsInput := model.CloningInput{
Name: "test",
}
// when
path := handler.GetChartsPath(chartsInput, projectID, false)
// then
assert.Equal(t, "/tmp/test/test/faults/", path)
}

// TestReadExperimentFile is used to test the ReadExperimentFile function
Expand Down Expand Up @@ -273,6 +286,7 @@ func TestGetChartsData(t *testing.T) {
RepoBranch: "master",
IsPrivate: false,
},
isError: false,
},
{
name: "invalid url",
Expand All @@ -290,7 +304,7 @@ func TestGetChartsData(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
if tc.isError {
// when
chartsPath := handler.GetChartsPath(tc.repoData, tc.projectID)
chartsPath := handler.GetChartsPath(tc.repoData, tc.projectID, false)
_, err := handler.GetChartsData(chartsPath)
// then
assert.Error(t, err)
Expand All @@ -300,7 +314,7 @@ func TestGetChartsData(t *testing.T) {

err := chaosHubOps.GitClone(tc.repoData, tc.projectID)
assert.NoError(t, err)
chartsPath := handler.GetChartsPath(tc.repoData, tc.projectID)
chartsPath := handler.GetChartsPath(tc.repoData, tc.projectID, true)
// when
_, err = handler.GetChartsData(chartsPath)
// then
Expand Down
Loading