Compare commits

..

1 commit

Author SHA1 Message Date
Marie
b0ecd92a8e update community information with updated links 2022-04-12 00:42:00 -04:00
23 changed files with 36 additions and 282 deletions

View file

@ -4,9 +4,9 @@ Bugs or Issues? Please create a new topic in our Discourse forum.
We are migrating all Drone repositories to Discourse for bug tracking.
New GitHub issues may be automatically deleted.
https://community.harness.io/
https://community.harness.io/c/bugs/17
https://community.harness.io/c/ideas/11
https://discourse.drone.io/
https://discourse.drone.io/c/bugs
https://discourse.drone.io/c/ideas
Failing Builds? Please do not use GitHub issues for generic support
questions. Instead please use Stack Overflow:

10
.github/readme.md vendored
View file

@ -19,16 +19,16 @@ Drone is a continuous delivery system built on container technology. Drone uses
## Community and Support
[Harness Community Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-y4hdqh7p-RVuEQyIl5Hcx4Ck8VCvzBw) - Join the #drone slack channel to connect with our engineers and other users running Drone CI.
</br>
[Harness Community Forum](https://community.harness.io/) - Ask questions, find answers, and help other users.
</br>
[Report A Bug](https://community.harness.io/c/bugs/17) - Find a bug? Please report in our forum under Drone Bugs. Please provide screenshots and steps to reproduce.
</br>
[Events](https://www.meetup.com/harness/) - Keep up to date with Drone events and check out previous events [here](https://www.youtube.com/watch?v=Oq34ImUGcHA&list=PLXsYHFsLmqf3zwelQDAKoVNmLeqcVsD9o).
## Contributing
We encourage you to contribute to Drone! Whether that's joining in on the community slack or discourse, or contributing pull requests / documentation changes or raising issues.
We encourage you to contribute to Drone! whether thats joining in on the community slack or discourse, or contributing pull requests / documentation changes or raising issues.
## Code of Conduct
@ -107,7 +107,7 @@ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator
You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens.
Next we tag the PR's with the fixes or enhancements labels. If the PR does not fulfill the requirements, do not add a label.
Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label.
**Before moving on make sure to update the version file `version/version.go && version/version_test.go`.**

View file

@ -1,3 +1,2 @@
since-tag=v2.0.4
issues=false

View file

@ -1,43 +1,5 @@
# Changelog
## [v2.12.1](https://github.com/harness/drone/tree/v2.12.1) (2022-06-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.12.0...v2.12.1)
**Fixed bugs:**
- \(bug\) - fix original template scripts & remove amend scripts [\#3229](https://github.com/harness/drone/pull/3229) ([eoinmcafee00](https://github.com/eoinmcafee00))
- \(bug\) - remove unique index on template name [\#3226](https://github.com/harness/drone/pull/3226) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Added OAuth2 token refresher for Gitlab [\#3215](https://github.com/harness/drone/pull/3215) ([EndymionWight](https://github.com/EndymionWight))
**Merged pull requests:**
- \(maint\) fix starlark test on windows [\#3230](https://github.com/harness/drone/pull/3230) ([tphoney](https://github.com/tphoney))
- \(maint\) fix unit tests so they pass on windows [\#3228](https://github.com/harness/drone/pull/3228) ([tphoney](https://github.com/tphoney))
- Update Readme to Fix Typo [\#3223](https://github.com/harness/drone/pull/3223) ([hrittikhere](https://github.com/hrittikhere))
- \(bug\) add unit test for comments in template file [\#3221](https://github.com/harness/drone/pull/3221) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Bump scm version to v1.24.0 [\#3219](https://github.com/harness/drone/pull/3219) ([kit101](https://github.com/kit101))
## [v2.12.0](https://github.com/harness/drone/tree/v2.12.0) (2022-05-16)
[Full Changelog](https://github.com/harness/drone/compare/v2.11.1...v2.12.0)
**Implemented enhancements:**
- bump SCM version to v1.21.1 [\#3204](https://github.com/harness/drone/pull/3204) ([d1wilko](https://github.com/d1wilko))
- bump ui version [\#3202](https://github.com/harness/drone/pull/3202) ([d1wilko](https://github.com/d1wilko))
**Fixed bugs:**
- \(fix\) update drone ui to 2.8.2 [\#3211](https://github.com/harness/drone/pull/3211) ([tphoney](https://github.com/tphoney))
- \(dron-267\) correctly set parent for promotion retry [\#3210](https://github.com/harness/drone/pull/3210) ([tphoney](https://github.com/tphoney))
**Merged pull requests:**
- release prep v2.12.0 [\#3214](https://github.com/harness/drone/pull/3214) ([tphoney](https://github.com/tphoney))
- fixing URL [\#3208](https://github.com/harness/drone/pull/3208) ([dnielsen](https://github.com/dnielsen))
- update community information with updated links [\#3199](https://github.com/harness/drone/pull/3199) ([mrsantons](https://github.com/mrsantons))
## [v2.11.1](https://github.com/harness/drone/tree/v2.11.1) (2022-03-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.11.0...v2.11.1)
@ -46,10 +8,6 @@
- ignore nil repos in list and add better debugging [\#3196](https://github.com/harness/drone/pull/3196) ([d1wilko](https://github.com/d1wilko))
**Merged pull requests:**
- \(maint\) release prep for 2.11.1 [\#3197](https://github.com/harness/drone/pull/3197) ([d1wilko](https://github.com/d1wilko))
## [v2.11.0](https://github.com/harness/drone/tree/v2.11.0) (2022-03-08)
[Full Changelog](https://github.com/harness/drone/compare/v2.10.0...v2.11.0)

View file

@ -21,7 +21,7 @@ Drone Non-Commercial License
Contributor: Drone.IO, Inc.
Source Code: https://github.com/harness/drone
Source Code: https://github.com/drone/drone
This license lets you use and share this software for free,
with a trial-length time limit on commercial use. Specifically:

View file

@ -180,13 +180,7 @@ func provideGitlabClient(config config.Config) *scm.Client {
}
client.Client = &http.Client{
Transport: &oauth2.Transport{
Scheme: oauth2.SchemeBearer,
Source: &oauth2.Refresher{
ClientID: config.GitLab.ClientID,
ClientSecret: config.GitLab.ClientSecret,
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
},
Base: defaultTransport(config.GitLab.SkipVerify),
},
}

View file

@ -197,14 +197,6 @@ func provideRefresher(config config.Config) *oauth2.Refresher {
Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.Gitea.SkipVerify),
}
case config.GitLab.ClientID != "":
return &oauth2.Refresher{
ClientID: config.GitLab.ClientID,
ClientSecret: config.GitLab.ClientSecret,
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.GitLab.SkipVerify),
}
case config.Gitee.ClientID != "":
return &oauth2.Refresher{
ClientID: config.Gitee.ClientID,

4
go.mod
View file

@ -14,13 +14,13 @@ require (
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
github.com/drone/drone-ui v2.8.2+incompatible
github.com/drone/drone-ui v2.7.1+incompatible
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629
github.com/drone/funcmap v0.0.0-20210823160631-9e9dec149056
github.com/drone/go-license v1.0.2
github.com/drone/go-login v1.1.0
github.com/drone/go-scm v1.24.0
github.com/drone/go-scm v1.20.0
github.com/drone/signal v1.0.0
github.com/dustin/go-humanize v1.0.0
github.com/go-chi/chi v3.3.3+incompatible

12
go.sum
View file

@ -73,13 +73,17 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27 h1:58xKlW/Kwp/Apz+R5qNGzBUIzfq1Z57L7Udz1B6bgWE=
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af h1:I+xfWPZLMaskFvfFO5fEJ6tVI1Q9bWR9tuORZeaCTPo=
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-runtime v1.0.7-0.20190729202838-87c84080f4a1/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
github.com/drone/drone-ui v2.8.2+incompatible h1:7F/MlcSEIZVi5VND/qmOnDDwQOkgqwsCVOQOsGJ2HJc=
github.com/drone/drone-ui v2.8.2+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-ui v2.7.1+incompatible h1:2RPN9/ZBMyJtcX+YBkf6eXz3k2LOHS/j8cPtH7mNfXA=
github.com/drone/drone-ui v2.7.1+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4 h1:XsstoCeXC2t8lA9OLTdoFwckaptqahxwjCWsenySfX8=
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4/go.mod h1:QsqliFK8nG04AHFN9tTn9XJomRBQHD4wcejWW1uz/10=
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 h1:rIaZZalMGGPb2cU/+ypuggZ8aMlpa17RUlJUtsMv8pw=
@ -90,8 +94,8 @@ github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrko
github.com/drone/go-license v1.0.2/go.mod h1:fGRHf+F1cEaw3YVYiJ6js3G3dVhcxyS617RnNRUMsms=
github.com/drone/go-login v1.1.0 h1:anQFRh2Z5ketEJ/LvL6SJ6rIwDdfysGXK5bSXkFLInI=
github.com/drone/go-login v1.1.0/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
github.com/drone/go-scm v1.24.0 h1:wE6bP9gnuyyKJStnl6wl0npt/SBQumjE9jilQAcFy6Q=
github.com/drone/go-scm v1.24.0/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
github.com/drone/go-scm v1.20.0 h1:SGB8TnE/85rklK+Gb3ZRTHQRt2atSCFHgtDKNqPwBQU=
github.com/drone/go-scm v1.20.0/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=

View file

@ -64,7 +64,6 @@ func HandleRetry(
}
hook := &core.Hook{
Parent: prev.Number,
Trigger: user.Login,
Event: prev.Event,
Action: prev.Action,

View file

@ -797,19 +797,3 @@ func (mr *MockUserServiceMockRecorder) FindLogin(arg0, arg1 interface{}) *gomock
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLogin", reflect.TypeOf((*MockUserService)(nil).FindLogin), arg0, arg1)
}
// ListEmail mocks base method
func (m *MockUserService) ListEmail(arg0 context.Context, arg1 scm.ListOptions) ([]*scm.Email, *scm.Response, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListEmail", arg0, arg1)
ret0, _ := ret[0].([]*scm.Email)
ret1, _ := ret[1].(*scm.Response)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// ListEmail indicates an expected call of ListEmail.
func (mr *MockUserServiceMockRecorder) ListEmail(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEmail", reflect.TypeOf((*MockUserService)(nil).ListEmail), arg0, arg1)
}

View file

@ -2,8 +2,6 @@ package jsonnet
import (
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -46,19 +44,13 @@ func TestParse(t *testing.T) {
req.Config.Data = string(before)
got, err := Parse(req, nil, 0, template, templateData)
parsedFile, err := Parse(req, nil, 0, template, templateData)
if err != nil {
t.Error(err)
return
}
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
if want, got := parsedFile, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}
@ -90,19 +82,13 @@ func TestParseJsonnetNotTemplateFile(t *testing.T) {
req.Repo.Config = "plugin.jsonnet"
req.Config.Data = string(before)
got, err := Parse(req, nil, 0, nil, nil)
parsedFile, err := Parse(req, nil, 0, nil, nil)
if err != nil {
t.Error(err)
return
}
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
if want, got := parsedFile, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -16,8 +16,6 @@ package converter
import (
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -119,14 +117,7 @@ func TestConvert_Multi(t *testing.T) {
return
}
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
if want, got := config.Data, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -17,8 +17,6 @@ package converter
import (
"encoding/json"
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -236,14 +234,7 @@ func TestTemplatePluginConvertJsonnet(t *testing.T) {
return
}
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
if want, got := config.Data, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}
@ -397,7 +388,6 @@ func TestTemplatePluginConvertYaml(t *testing.T) {
t.Errorf("Want %q got %q", want, got)
}
}
// tests to check error is thrown if user has already loaded a template file of invalid extension
// and refers to it in the drone.yml file
func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) {
@ -446,65 +436,3 @@ func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) {
t.Errorf("template extension invalid. must be yaml, starlark or jsonnet")
}
}
func TestTemplatePluginConvertYamlWithComment(t *testing.T) {
templateArgs, err := ioutil.ReadFile("testdata/yaml.template.comment.yml")
if err != nil {
t.Error(err)
return
}
req := &core.ConvertArgs{
Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b99387d012c1",
},
Repo: &core.Repository{
Slug: "octocat/hello-world",
Config: ".drone.yml",
Namespace: "octocat",
},
Config: &core.Config{
Data: string(templateArgs),
},
}
beforeInput, err := ioutil.ReadFile("testdata/yaml.input.yml")
if err != nil {
t.Error(err)
return
}
after, err := ioutil.ReadFile("testdata/yaml.input.golden")
if err != nil {
t.Error(err)
return
}
template := &core.Template{
Name: "plugin.yaml",
Data: string(beforeInput),
Namespace: "octocat",
}
controller := gomock.NewController(t)
defer controller.Finish()
templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespace).Return(template, nil)
plugin := Template(templates, 0)
config, err := plugin.Convert(noContext, req)
if err != nil {
t.Error(err)
return
}
if config == nil {
t.Error("Want non-nil configuration")
return
}
if want, got := config.Data, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -1,8 +0,0 @@
---
# this is a comment
kind: template
load: plugin.yaml
data:
stepName: my_step
image: my_image
commands: my_command

View file

@ -48,7 +48,6 @@ func Connect() (*db.DB, error) {
func Reset(d *db.DB) {
d.Lock(func(tx db.Execer, _ db.Binder) error {
tx.Exec("DELETE FROM cron")
tx.Exec("DELETE FROM cards")
tx.Exec("DELETE FROM logs")
tx.Exec("DELETE FROM steps")
tx.Exec("DELETE FROM stages")
@ -57,7 +56,6 @@ func Reset(d *db.DB) {
tx.Exec("DELETE FROM perms")
tx.Exec("DELETE FROM repos")
tx.Exec("DELETE FROM users")
tx.Exec("DELETE FROM templates")
tx.Exec("DELETE FROM orgsecrets")
return nil
})

View file

@ -160,10 +160,6 @@ var migrations = []struct {
name: "create-table-template",
stmt: createTableTemplate,
},
{
name: "create-index-template-namespace",
stmt: createIndexTemplateNamespace,
},
{
name: "alter-table-steps-add-column-step-depends-on",
stmt: alterTableStepsAddColumnStepDependsOn,
@ -696,16 +692,14 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
var createTableTemplate = `
CREATE TABLE IF NOT EXISTS templates (
template_id SERIAL PRIMARY KEY
,template_name TEXT
,template_name TEXT UNIQUE
,template_namespace VARCHAR(50)
,template_data BYTEA
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name, template_namespace)
);
`
var createIndexTemplateNamespace = `
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
`

View file

@ -2,7 +2,7 @@
CREATE TABLE IF NOT EXISTS templates (
template_id SERIAL PRIMARY KEY
,template_name TEXT
,template_name TEXT UNIQUE
,template_namespace VARCHAR(50)
,template_data BYTEA
,template_created INTEGER
@ -10,6 +10,4 @@ CREATE TABLE IF NOT EXISTS templates (
,UNIQUE(template_name, template_namespace)
);
-- name: create-index-template-namespace
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);

View file

@ -160,10 +160,6 @@ var migrations = []struct {
name: "create-table-templates",
stmt: createTableTemplates,
},
{
name: "create-index-template-namespace",
stmt: createIndexTemplateNamespace,
},
{
name: "alter-table-steps-add-column-step-depends-on",
stmt: alterTableStepsAddColumnStepDependsOn,
@ -698,16 +694,14 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
var createTableTemplates = `
CREATE TABLE IF NOT EXISTS templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT
,template_name TEXT UNIQUE
,template_namespace TEXT COLLATE NOCASE
,template_data BLOB
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
,UNIQUE(template_name, template_namespace)
);
`
var createIndexTemplateNamespace = `
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
`

View file

@ -2,14 +2,12 @@
CREATE TABLE IF NOT EXISTS templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT
,template_name TEXT UNIQUE
,template_namespace TEXT COLLATE NOCASE
,template_data BLOB
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
,UNIQUE(template_name, template_namespace)
);
-- name: create-index-template-namespace
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);

View file

@ -2,7 +2,6 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
//go:build !oss
// +build !oss
package template
@ -30,7 +29,7 @@ func TestTemplate(t *testing.T) {
}()
store := New(conn).(*templateStore)
t.Run("TestTemplates", testTemplateCreate(store))
t.Run("Create", testTemplateCreate(store))
}
func testTemplateCreate(store *templateStore) func(t *testing.T) {
@ -51,8 +50,6 @@ func testTemplateCreate(store *templateStore) func(t *testing.T) {
t.Errorf("Want template Id assigned, got %d", item.Id)
}
t.Run("CreateSameNameDiffOrg", testCreateWithSameNameDiffOrg(store))
t.Run("CreateSameNameSameOrgShouldError", testCreateSameNameSameOrgShouldError(store))
t.Run("Find", testTemplateFind(store, item))
t.Run("FindName", testTemplateFindName(store))
t.Run("ListAll", testTemplateListAll(store))
@ -62,43 +59,6 @@ func testTemplateCreate(store *templateStore) func(t *testing.T) {
}
}
func testCreateWithSameNameDiffOrg(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
item := &core.Template{
Id: 1,
Name: "my_template",
Namespace: "my_org2",
Data: "some_template_data",
Created: 1,
Updated: 2,
}
err := store.Create(noContext, item)
if err != nil {
t.Error(err)
}
if item.Id == 0 {
t.Errorf("Want template Id assigned, got %d", item.Id)
}
}
}
func testCreateSameNameSameOrgShouldError(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
item := &core.Template{
Id: 3,
Name: "my_template",
Namespace: "my_org2",
Data: "some_template_data",
Created: 1,
Updated: 2,
}
err := store.Create(noContext, item)
if err == nil {
t.Error(err)
}
}
}
func testTemplateFind(store *templateStore, template *core.Template) func(t *testing.T) {
return func(t *testing.T) {
item, err := store.Find(noContext, template.Id)
@ -135,20 +95,6 @@ func testTemplate(item *core.Template) func(t *testing.T) {
}
}
func testTemplate2(item *core.Template) func(t *testing.T) {
return func(t *testing.T) {
if got, want := item.Name, "my_template"; got != want {
t.Errorf("Want template name %q, got %q", want, got)
}
if got, want := item.Data, "some_template_data"; got != want {
t.Errorf("Want template data %q, got %q", want, got)
}
if got, want := item.Namespace, "my_org2"; got != want {
t.Errorf("Want template org %q, got %q", want, got)
}
}
}
func testTemplateListAll(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
list, err := store.ListAll(noContext)
@ -156,11 +102,10 @@ func testTemplateListAll(store *templateStore) func(t *testing.T) {
t.Error(err)
return
}
if got, want := len(list), 2; got != want {
if got, want := len(list), 1; got != want {
t.Errorf("Want count %d, got %d", want, got)
} else {
t.Run("Fields", testTemplate(list[0]))
t.Run("Fields", testTemplate2(list[1]))
}
}
}

View file

@ -25,7 +25,7 @@ var (
// VersionMajor is for an API incompatible changes.
VersionMajor int64 = 2
// VersionMinor is for functionality in a backwards-compatible manner.
VersionMinor int64 = 12
VersionMinor int64 = 11
// VersionPatch is for backwards-compatible bug fixes.
VersionPatch int64 = 1
// VersionPre indicates prerelease.

View file

@ -10,7 +10,7 @@ package version
import "testing"
func TestVersion(t *testing.T) {
if got, want := Version.String(), "2.12.1"; got != want {
if got, want := Version.String(), "2.11.1"; got != want {
t.Errorf("Want version %s, got %s", want, got)
}
}