Skip to content

Commit

Permalink
[WIP]Fixed:Compilation errors in choas_hub/handler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
punithnayak committed Aug 2, 2023
1 parent 28f9079 commit e0ad279
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
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

0 comments on commit e0ad279

Please sign in to comment.