mirror of https://github.com/databricks/cli.git
more test
This commit is contained in:
parent
0a68fb34f9
commit
8202aafc78
|
@ -3,6 +3,7 @@ package template
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/databricks/cli/libs/git"
|
||||
)
|
||||
|
@ -37,7 +38,7 @@ var ErrCustomSelected = errors.New("custom template selected")
|
|||
// Prompts the user if needed.
|
||||
func (r Resolver) Resolve(ctx context.Context) (*Template, error) {
|
||||
if r.Tag != "" && r.Branch != "" {
|
||||
return nil, errors.New("only one of --tag or --branch can be specified")
|
||||
return nil, fmt.Errorf("only one of --tag or --branch can be specified")
|
||||
}
|
||||
|
||||
// Git ref to use for template initialization
|
||||
|
|
|
@ -66,7 +66,7 @@ func TestTemplateResolverForDefaultTemplates(t *testing.T) {
|
|||
assert.Equal(t, "/config/file", tmpl.Writer.(*writerWithTelemetry).configPath)
|
||||
}
|
||||
|
||||
func TestTemplateResolverForCustomTemplate(t *testing.T) {
|
||||
func TestTemplateResolverForCustomUrl(t *testing.T) {
|
||||
r := Resolver{
|
||||
TemplatePathOrUrl: "https://www.example.com/abc",
|
||||
Tag: "tag",
|
||||
|
@ -77,6 +77,8 @@ func TestTemplateResolverForCustomTemplate(t *testing.T) {
|
|||
tmpl, err := r.Resolve(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, Custom, tmpl.name)
|
||||
|
||||
// Assert reader configuration
|
||||
assert.Equal(t, "https://www.example.com/abc", tmpl.Reader.(*gitReader).gitUrl)
|
||||
assert.Equal(t, "tag", tmpl.Reader.(*gitReader).ref)
|
||||
|
@ -85,3 +87,21 @@ func TestTemplateResolverForCustomTemplate(t *testing.T) {
|
|||
// Assert writer configuration
|
||||
assert.Equal(t, "/config/file", tmpl.Writer.(*defaultWriter).configPath)
|
||||
}
|
||||
|
||||
func TestTemplateResolverForCustomPath(t *testing.T) {
|
||||
r := Resolver{
|
||||
TemplatePathOrUrl: "/custom/path",
|
||||
ConfigFile: "/config/file",
|
||||
}
|
||||
|
||||
tmpl, err := r.Resolve(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, Custom, tmpl.name,)
|
||||
|
||||
// Assert reader configuration
|
||||
assert.Equal(t, "/custom/path", tmpl.Reader.(*localReader).path)
|
||||
|
||||
// Assert writer configuration
|
||||
assert.Equal(t, "/config/file", tmpl.Writer.(*defaultWriter).configPath)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue