shoebill/pkg/config/repository_test.go

57 lines
1.1 KiB
Go

package config_test
import (
"fmt"
"testing"
"git.badhouseplants.net/allanger/shoebill/pkg/config"
"github.com/stretchr/testify/assert"
)
func TestBothRepoKindsError(t *testing.T) {
repo := &config.Repository{
Name: "test",
Helm: &config.RepositoryHelm{
URL: "test",
},
Git: &config.RepositoryGit{
URL: "test",
Ref: "test",
Path: "test",
},
}
err := repo.ValidateConfig()
assert.ErrorContains(t, err,
"repo test is invalid, only one repo kind can be specified",
fmt.Sprintf("haven't got an unexpected err: %s", err))
}
func TestHelmRepoNoError(t *testing.T) {
repo := &config.Repository{
Name: "test",
Helm: &config.RepositoryHelm{
URL: "test",
},
}
err := repo.ValidateConfig()
assert.NoError(t, err,
fmt.Sprintf("got an unexpected err: %s", err))
}
func TestGitRepoNoError(t *testing.T) {
repo := &config.Repository{
Name: "test",
Git: &config.RepositoryGit{
URL: "test",
Ref: "test",
Path: "test",
},
}
err := repo.ValidateConfig()
assert.NoError(t, err,
fmt.Sprintf("got an unexpected err: %s", err))
}