Compare commits
3 commits
537e780188
...
94c7791d26
Author | SHA1 | Date | |
---|---|---|---|
94c7791d26 | |||
b22d060cc6 | |||
2e41d3d004 |
3 changed files with 32 additions and 1 deletions
|
@ -1,4 +1,3 @@
|
||||||
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,6 +5,7 @@ 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) {
|
||||||
|
@ -12,6 +13,13 @@ 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) {
|
||||||
|
@ -37,4 +45,8 @@ 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,10 +1,12 @@
|
||||||
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) {
|
||||||
|
@ -12,3 +14,21 @@ 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