"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugin/converter/template_test.go" between
drone-2.15.0.tar.gz and drone-2.16.0.tar.gz

About: Drone is a Continuous Delivery system built on (docker) container technology.

template_test.go  (drone-2.15.0):template_test.go  (drone-2.16.0)
skipping to change at line 76 skipping to change at line 76
Data: string(beforeInput), Data: string(beforeInput),
Namespace: "octocat", Namespace: "octocat",
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if config == nil { if config == nil {
t.Error("Want non-nil configuration") t.Error("Want non-nil configuration")
return return
} }
if want, got := config.Data, string(after); want != got { if want, got := config.Data, string(after); want != got {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }
func TestTemplatePluginConvertNotYamlFile(t *testing.T) { func TestTemplatePluginConvertNotYamlFile(t *testing.T) {
plugin := Template(nil, 0) plugin := Template(nil, 0, 0)
req := &core.ConvertArgs{ req := &core.ConvertArgs{
Build: &core.Build{ Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b99387d012c1", After: "3d21ec53a331a6f037a91c368710b99387d012c1",
}, },
Repo: &core.Repository{ Repo: &core.Repository{
Slug: "octocat/hello-world", Slug: "octocat/hello-world",
Config: ".drone.star", Config: ".drone.star",
}, },
Config: &core.Config{}, Config: &core.Config{},
} }
skipping to change at line 123 skipping to change at line 123
t.Errorf("Expect nil config returned for non-starlark files") t.Errorf("Expect nil config returned for non-starlark files")
} }
} }
func TestTemplatePluginConvertDroneFileTypePipeline(t *testing.T) { func TestTemplatePluginConvertDroneFileTypePipeline(t *testing.T) {
args, err := ioutil.ReadFile("testdata/drone.yml") args, err := ioutil.ReadFile("testdata/drone.yml")
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
plugin := Template(nil, 0) plugin := Template(nil, 0, 0)
req := &core.ConvertArgs{ req := &core.ConvertArgs{
Build: &core.Build{ Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b99387d012c1", After: "3d21ec53a331a6f037a91c368710b99387d012c1",
}, },
Repo: &core.Repository{ Repo: &core.Repository{
Slug: "octocat/hello-world", Slug: "octocat/hello-world",
Config: ".drone.yml", Config: ".drone.yml",
}, },
Config: &core.Config{Data: string(args)}, Config: &core.Config{Data: string(args)},
} }
skipping to change at line 164 skipping to change at line 164
t.Error(err) t.Error(err)
return return
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), gomock.Any(), g omock.Any()).Return(nil, dummyErr) templates.EXPECT().FindName(gomock.Any(), gomock.Any(), g omock.Any()).Return(nil, dummyErr)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
req := &core.ConvertArgs{ req := &core.ConvertArgs{
Build: &core.Build{ Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b9938 7d012c1", After: "3d21ec53a331a6f037a91c368710b9938 7d012c1",
}, },
Repo: &core.Repository{ Repo: &core.Repository{
Slug: "octocat/hello-world", Slug: "octocat/hello-world",
Config: ".drone." + extension, Config: ".drone." + extension,
}, },
Config: &core.Config{Data: string(args)}, Config: &core.Config{Data: string(args)},
} }
skipping to change at line 217 skipping to change at line 217
defer controller.Finish() defer controller.Finish()
template := &core.Template{ template := &core.Template{
Name: "plugin.starlark", Name: "plugin.starlark",
Data: "", Data: "",
} }
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(nil, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(nil, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if config != nil { if config != nil {
t.Errorf("template converter: template name given not found") t.Errorf("template converter: template name given not found")
} }
} }
func TestTemplatePluginConvertJsonnet(t *testing.T) { func TestTemplatePluginConvertJsonnet(t *testing.T) {
templateArgs, err := ioutil.ReadFile("testdata/jsonnet.template.yml") templateArgs, err := ioutil.ReadFile("testdata/jsonnet.template.yml")
if err != nil { if err != nil {
skipping to change at line 270 skipping to change at line 270
Data: string(beforeInput), Data: string(beforeInput),
Namespace: "octocat", Namespace: "octocat",
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if config == nil { if config == nil {
t.Error("Want non-nil configuration") t.Error("Want non-nil configuration")
return return
} }
skipping to change at line 349 skipping to change at line 349
Data: string(beforeInput), Data: string(beforeInput),
Namespace: "octocat", Namespace: "octocat",
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if config == nil { if config == nil {
t.Error("Want non-nil configuration") t.Error("Want non-nil configuration")
return return
} }
skipping to change at line 427 skipping to change at line 427
Data: string(beforeInput), Data: string(beforeInput),
Namespace: "octocat", Namespace: "octocat",
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if config == nil { if config == nil {
t.Error("Want non-nil configuration") t.Error("Want non-nil configuration")
return return
} }
skipping to change at line 486 skipping to change at line 486
Data: string(beforeInput), Data: string(beforeInput),
Namespace: "octocat", Namespace: "octocat",
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if config != nil { if config != nil {
t.Errorf("template extension invalid. must be yaml, starlark or j sonnet") t.Errorf("template extension invalid. must be yaml, starlark or j sonnet")
} }
} }
func TestTemplatePluginConvertYamlWithComment(t *testing.T) { func TestTemplatePluginConvertYamlWithComment(t *testing.T) {
templateArgs, err := ioutil.ReadFile("testdata/yaml.template.comment.yml" ) templateArgs, err := ioutil.ReadFile("testdata/yaml.template.comment.yml" )
if err != nil { if err != nil {
t.Error(err) t.Error(err)
skipping to change at line 538 skipping to change at line 538
Data: string(beforeInput), Data: string(beforeInput),
Namespace: "octocat", Namespace: "octocat",
} }
controller := gomock.NewController(t) controller := gomock.NewController(t)
defer controller.Finish() defer controller.Finish()
templates := mock.NewMockTemplateStore(controller) templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil) templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespa ce).Return(template, nil)
plugin := Template(templates, 0) plugin := Template(templates, 0, 0)
config, err := plugin.Convert(noContext, req) config, err := plugin.Convert(noContext, req)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if config == nil { if config == nil {
t.Error("Want non-nil configuration") t.Error("Want non-nil configuration")
return return
} }
 End of changes. 10 change blocks. 
10 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)