Compare commits
3 commits
94c7791d26
...
537e780188
Author | SHA1 | Date | |
---|---|---|---|
537e780188 | |||
3c4c6bdf80 | |||
aee989202b |
3 changed files with 1 additions and 32 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
skip_clone: true
|
||||||
steps:
|
steps:
|
||||||
- name: bump tag in deployment-repo
|
- name: bump tag in deployment-repo
|
||||||
image: git.ar21.de/aaron/kustomize-ci
|
image: git.ar21.de/aaron/kustomize-ci
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"git.ar21.de/yolokube/grafana-backuper/internal/config"
|
"git.ar21.de/yolokube/grafana-backuper/internal/config"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConfig_Validate_MissingFields(t *testing.T) {
|
func TestConfig_Validate_MissingFields(t *testing.T) {
|
||||||
|
@ -13,13 +12,6 @@ func TestConfig_Validate_MissingFields(t *testing.T) {
|
||||||
|
|
||||||
errs := cfg.Validate()
|
errs := cfg.Validate()
|
||||||
assert.Len(t, errs, 6) // Expecting 6 errors since all required fields are missing
|
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) {
|
func TestConfig_Validate_AllFieldsPresent(t *testing.T) {
|
||||||
|
@ -45,8 +37,4 @@ func TestConfig_Validate_PartiallyPopulated(t *testing.T) {
|
||||||
|
|
||||||
errs := cfg.Validate()
|
errs := cfg.Validate()
|
||||||
assert.Len(t, errs, 3) // Expecting 3 errors for missing GrafanaToken, GitPass, and GitBranch
|
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)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package git_test
|
package git_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.ar21.de/yolokube/grafana-backuper/pkg/git"
|
"git.ar21.de/yolokube/grafana-backuper/pkg/git"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewProject(t *testing.T) {
|
func TestNewProject(t *testing.T) {
|
||||||
|
@ -14,21 +12,3 @@ func TestNewProject(t *testing.T) {
|
||||||
assert.NotNil(t, project)
|
assert.NotNil(t, project)
|
||||||
assert.Equal(t, "https://example.com/repo.git", project.RepoURL)
|
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)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue