Compare commits

..

3 commits

Author SHA1 Message Date
94c7791d26
chore(deps): update golangci/golangci-lint docker tag to v1.62.2
Some checks failed
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline failed
ci/woodpecker/push/build unknown status
ci/woodpecker/push/deploy unknown status
2024-12-07 00:04:34 +01:00
b22d060cc6
test(config,git,logger): add some test functions
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/test unknown status
ci/woodpecker/push/build unknown status
ci/woodpecker/push/deploy unknown status
2024-12-06 23:56:18 +01:00
2e41d3d004
add woodpecker pipeline
All checks were successful
ci/woodpecker/pr/gofmt Pipeline was successful
ci/woodpecker/pr/vulncheck Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/push/vulncheck Pipeline was successful
ci/woodpecker/push/gofmt Pipeline was successful
ci/woodpecker/pr/deploy Pipeline was successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
2024-08-20 20:21:17 +02:00
3 changed files with 32 additions and 1 deletions

View file

@ -1,4 +1,3 @@
skip_clone: true
steps:
- name: bump tag in deployment-repo
image: git.ar21.de/aaron/kustomize-ci

View file

@ -5,6 +5,7 @@ import (
"git.ar21.de/yolokube/grafana-backuper/internal/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestConfig_Validate_MissingFields(t *testing.T) {
@ -12,6 +13,13 @@ func TestConfig_Validate_MissingFields(t *testing.T) {
errs := cfg.Validate()
assert.Len(t, errs, 6) // Expecting 6 errors since all required fields are missing
require.ErrorIs(t, errs[0], config.ErrInvalidGrafanaURL)
require.ErrorIs(t, errs[1], config.ErrInvalidAuthToken)
require.ErrorIs(t, errs[2], config.ErrInvalidRepoURL)
require.ErrorIs(t, errs[3], config.ErrInvalidGitUser)
require.ErrorIs(t, errs[4], config.ErrInvalidGitPass)
require.ErrorIs(t, errs[5], config.ErrInvalidBranchName)
}
func TestConfig_Validate_AllFieldsPresent(t *testing.T) {
@ -37,4 +45,8 @@ func TestConfig_Validate_PartiallyPopulated(t *testing.T) {
errs := cfg.Validate()
assert.Len(t, errs, 3) // Expecting 3 errors for missing GrafanaToken, GitPass, and GitBranch
require.ErrorIs(t, errs[0], config.ErrInvalidGrafanaURL)
require.ErrorIs(t, errs[1], config.ErrInvalidGitPass)
require.ErrorIs(t, errs[2], config.ErrInvalidBranchName)
}

View file

@ -1,10 +1,12 @@
package git_test
import (
"context"
"testing"
"git.ar21.de/yolokube/grafana-backuper/pkg/git"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewProject(t *testing.T) {
@ -12,3 +14,21 @@ func TestNewProject(t *testing.T) {
assert.NotNil(t, project)
assert.Equal(t, "https://example.com/repo.git", project.RepoURL)
}
func TestProject_Clone(t *testing.T) {
// Create a Project instance and clone the repository
project := git.NewProject("https://example.com/repo.git")
err := project.Clone(context.Background())
require.NoError(t, err)
}
func TestProject_Checkout(t *testing.T) {
project := git.NewProject("https://example.com/repo.git")
err := project.Clone(context.Background())
require.NoError(t, err)
project.Branch = "test-branch"
err = project.Checkout()
require.NoError(t, err)
}