"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugin/converter/starlark_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.

starlark_test.go  (drone-2.15.0):starlark_test.go  (drone-2.16.0)
skipping to change at line 27 skipping to change at line 27
import ( import (
"io/ioutil" "io/ioutil"
"runtime" "runtime"
"strings" "strings"
"testing" "testing"
"github.com/drone/drone/core" "github.com/drone/drone/core"
) )
func TestStarlarkConvert(t *testing.T) { func TestStarlarkConvert(t *testing.T) {
plugin := Starlark(true, 0) plugin := Starlark(true, 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{}, Config: &core.Config{},
skipping to change at line 105 skipping to change at line 105
}, },
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{
Data: string(before), Data: string(before),
}, },
} }
plugin := Starlark(true, 0) plugin := Starlark(true, 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
} }
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
skipping to change at line 137 skipping to change at line 137
got := config.Data got := config.Data
if want != got { if want != got {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }
// this test verifies the plugin is skipped when it has // this test verifies the plugin is skipped when it has
// not been explicitly enabled. // not been explicitly enabled.
func TestConvert_Skip(t *testing.T) { func TestConvert_Skip(t *testing.T) {
plugin := Starlark(false, 0) plugin := Starlark(false, 0, 0)
config, err := plugin.Convert(noContext, nil) config, err := plugin.Convert(noContext, nil)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if config != nil { if config != nil {
t.Errorf("Expect nil config returned when plugin disabled") t.Errorf("Expect nil config returned when plugin disabled")
} }
} }
// this test verifies the plugin is skipped when the config // this test verifies the plugin is skipped when the config
// file extension is not a starlark extension. // file extension is not a starlark extension.
func TestConvert_SkipYaml(t *testing.T) { func TestConvert_SkipYaml(t *testing.T) {
req := &core.ConvertArgs{ req := &core.ConvertArgs{
Repo: &core.Repository{ Repo: &core.Repository{
Config: ".drone.yaml", Config: ".drone.yaml",
}, },
} }
plugin := Starlark(true, 0) plugin := Starlark(true, 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.Errorf("Expect nil config returned for non-starlark files") t.Errorf("Expect nil config returned for non-starlark files")
} }
} }
// this test verifies the plugin returns error
// if the generated file size is exceeded.
func TestConvert_SizeLimit(t *testing.T) {
smallFileSizeLimit := uint64(1)
plugin := Starlark(true, 0, smallFileSizeLimit)
req := &core.ConvertArgs{
Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b99387d012c1",
},
Repo: &core.Repository{
Slug: "octocat/hello-world",
Config: ".drone.yml",
},
Config: &core.Config{},
}
before, err := ioutil.ReadFile("testdata/single.star")
if err != nil {
t.Error(err)
return
}
req.Repo.Config = "single.star"
req.Config.Data = string(before)
_, expectedError := plugin.Convert(noContext, req)
if expectedError == nil {
t.Error("Expected 'starlark: maximum file size exceeded' error")
return
}
}
 End of changes. 5 change blocks. 
4 lines changed or deleted 4 lines changed or added

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