forked from devstream-io/devstream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "dependsOn" in config, add config dependency check (devstre…
…am-io#270) * chore: merge main branch * docs: update docs for dependencies * feat: config dependency check with unit test * feat: config dependency check with unit test * chore: rename and add comments * fix: readme link error * fix: update dependsOn to array according to code review * feat: refactor dependsOn from str to array according to code review
- Loading branch information
1 parent
6bfccd0
commit f1ebfc7
Showing
10 changed files
with
117 additions
and
22 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
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
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,45 @@ | ||
package configloader | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDependencyPass(t *testing.T) { | ||
tools := []Tool{ | ||
{Name: "argocd", Plugin: Plugin{Kind: "argocd"}}, | ||
{Name: "argocdapp", Plugin: Plugin{Kind: "argocdapp"}, DependsOn: []string{"argocd.argocd"}}, | ||
} | ||
errors := validateDependency(tools) | ||
assert.Equal(t, len(errors), 0, "Dependency check passed.") | ||
|
||
} | ||
|
||
func TestDependencyNotExist(t *testing.T) { | ||
tools := []Tool{ | ||
{Name: "argocdapp", Plugin: Plugin{Kind: "argocdapp"}, DependsOn: []string{"argocd.argocd"}}, | ||
} | ||
errors := validateDependency(tools) | ||
assert.Equal(t, len(errors), 1) | ||
|
||
} | ||
|
||
func TestMultipleDependencies(t *testing.T) { | ||
tools := []Tool{ | ||
{Name: "argocd", Plugin: Plugin{Kind: "argocd"}}, | ||
{Name: "repo", Plugin: Plugin{Kind: "github"}}, | ||
{Name: "argocdapp", Plugin: Plugin{Kind: "argocdapp"}, DependsOn: []string{"argocd.argocd", "repo.github"}}, | ||
} | ||
errors := validateDependency(tools) | ||
assert.Equal(t, len(errors), 0) | ||
} | ||
|
||
func TestEmptyDependency(t *testing.T) { | ||
tools := []Tool{ | ||
{Name: "argocd", Plugin: Plugin{Kind: "argocd"}}, | ||
{Name: "argocdapp", Plugin: Plugin{Kind: "argocdapp"}, DependsOn: []string{}}, | ||
} | ||
errors := validateDependency(tools) | ||
assert.Equal(t, len(errors), 0) | ||
} |
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