diff --git a/.github/workflows/sonarcloud.yaml b/.github/workflows/sonarcloud.yaml index ecad52b..88e813a 100644 --- a/.github/workflows/sonarcloud.yaml +++ b/.github/workflows/sonarcloud.yaml @@ -23,7 +23,7 @@ jobs: with: experimental: true - run: mise run dev:lint --no-fail - - run: mise run test:unit --ci + - run: mise run test:unit - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@6bbd64e0cb2194e04addb429d669a9ee873eeeef env: diff --git a/.mise/tasks/dev/lint b/.mise/tasks/dev/lint index e68da60..5cbb55e 100755 --- a/.mise/tasks/dev/lint +++ b/.mise/tasks/dev/lint @@ -25,4 +25,8 @@ if test "$fix" = 0; then fixflags="--fix" fi -golangci-lint run --issues-exit-code="$nofail" $fixflags +golangci-lint run \ +--issues-exit-code="$nofail" \ +--max-issues-per-linter 0 \ +--max-same-issues 0 \ +$fixflags diff --git a/.mise/tasks/test/unit b/.mise/tasks/test/unit index bedc740..213b1a8 100755 --- a/.mise/tasks/test/unit +++ b/.mise/tasks/test/unit @@ -2,25 +2,7 @@ # mise sources=["go.mod", "go.sum", "internal/**/*", "cmd/**/*", "*.go"] # mise outputs=["build/unit_coverage.out", "build/unit_test_report.json"] -ci=1 - -handle_argument() { - echo "Argument '$1' not supported" >&2; exit 1 -} - -while test "$#" -gt 0; do - case "$1" in - --ci) ci=0; shift 1;; - - -*) echo "unknown option: $1" >&2; exit 1;; - *) handle_argument "$1"; shift 1;; - esac -done - mkdir -p build -if test "$ci" = 0; then - go test -coverprofile build/unit_coverage.out -json ./... > build/unit_test_report.json || true -else - go test -coverprofile build/unit_coverage.out ./... -fi +go test -json ./... > build/unit_test_report.json || true +go test -coverprofile build/unit_coverage.out ./... diff --git a/internal/configProvider/config_test.go b/internal/configProvider/config_test.go index 90f71dd..c58823e 100644 --- a/internal/configProvider/config_test.go +++ b/internal/configProvider/config_test.go @@ -35,11 +35,12 @@ import ( ) var testYamlFilePath = "testdata/config.yaml" +var securitySaltFilePath = "testdata/security.salt" +var securitySiteKeyFilePath = "testdata/security.sitekey" var testFilePath = "testdata/test.file" var databaseUserKey = "database.user" var databasePasswordKey = "database.password" var nonExistentYamlFilePath = "testdata/non-existent.yaml" -var newUserNameString = "new-username" var newPasswordString = "new-password 42 c@t" var rootConfigYamlPath = "/config.yaml" @@ -227,7 +228,7 @@ func TestNewConfigProvider(t *testing.T) { err := os.WriteFile(tempFile, yamlContent, 0644) require.NoError(t, err) - c, err := NewConfigProvider(tempFile, nil, []string{testFilePath}, validator.NewValidator()) + c, err := NewConfigProvider(tempFile, nil, []string{securitySaltFilePath, securitySiteKeyFilePath}, validator.NewValidator()) require.NoError(t, err) require.Equal(t, initialPw, c.k.String(databasePasswordKey)) @@ -237,7 +238,7 @@ func TestNewConfigProvider(t *testing.T) { err = os.WriteFile(tempFile, newYamlContent, 0644) require.NoError(t, err) - // sleep for a 100 milliseconds to allow the file watcher to pick up the + // sleep for 100 milliseconds to allow the file watcher to pick up the // change and reload the config time.Sleep(100 * time.Millisecond) @@ -269,7 +270,7 @@ func TestNewConfigProviderErrorUpdateFailValidate(t *testing.T) { err = os.WriteFile(tempFile, yamlContent, 0644) require.NoError(t, err) - c, err := NewConfigProvider(tempFile, nil, []string{testFilePath}, validator.NewValidator()) + c, err := NewConfigProvider(tempFile, nil, []string{securitySaltFilePath, securitySiteKeyFilePath}, validator.NewValidator()) require.NoError(t, err) cfg := c.Get() @@ -311,7 +312,7 @@ func TestConfigProviderGet(t *testing.T) { err = os.WriteFile(tempFile, yamlContent, 0644) require.NoError(t, err) - c, err := NewConfigProvider(tempFile, nil, []string{testFilePath}, validator.NewValidator()) + c, err := NewConfigProvider(tempFile, nil, []string{securitySaltFilePath, securitySiteKeyFilePath}, validator.NewValidator()) require.NoError(t, err) cfg := c.Get()