Skip to content

Commit

Permalink
tests: add mandatory virustotal test
Browse files Browse the repository at this point in the history
chore: atlas migrate in ci
  • Loading branch information
Vilsol committed Oct 2, 2024
1 parent 98442f5 commit b43ef59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
- name: Hash migrations
run: atlas migrate hash --dir "file://migrations/sql?format=golang-migrate"

- name: Make sure all changes generated
run: atlas migrate diff ci_migration --dir "file://migrations/sql?format=golang-migrate" --to "ent://db/schema" --dev-url "docker://postgres/16/test?search_path=public"

- name: Ensure no changes
run: git diff --exit-code

Expand Down
12 changes: 11 additions & 1 deletion tests/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const testModPath = "testdata/FicsitRemoteMonitoring-0.10.3.smod"
// TODO Add rate limit test

func TestVersionSuccess(t *testing.T) {
RunVersionTestWrapper(t, testModPath, viper.IsSet("virustotal.key") && viper.GetString("virustotal.key") != "", "FicsitRemoteMonitoring", "")
RunVersionTestWrapper(t, testModPath, false, "FicsitRemoteMonitoring", "")
}

func TestVersionVirustotal(t *testing.T) {
RunVersionTestWrapper(t, testModPath, true, "FicsitRemoteMonitoring", "")
}

func TestVersionWrongModReference(t *testing.T) {
Expand Down Expand Up @@ -72,6 +76,12 @@ func RunVersionTestWrapper(t *testing.T, modFilePath string, executeVirusCheck b
}

func RunVersionTest(ctx context.Context, t *testing.T, client *graphql.Client, modFilePath string, executeVirusCheck bool, modReference string, reuseModID string, expectError string) string {
if executeVirusCheck && !(viper.IsSet("virustotal.key") && viper.GetString("virustotal.key") != "") {
println("missing virustotal key from config")
t.FailNow()
return ""
}

viper.Set("skip-virus-check", !executeVirusCheck)

token, _, err := makeUser(ctx)
Expand Down

0 comments on commit b43ef59

Please sign in to comment.