Example #1
0
func TestRemoteProcessing(t *testing.T) {
	assert := assert.New(t)

	rs := Remotes{
		`origin`: Remote{
			Name:     `origin`,
			FetchURL: `https://github.com/origin/fetch`,
			PushURL:  `https://github.com/origin/push`,
		},
		`upstream`: Remote{
			Name:     `upstream`,
			FetchURL: `https://github.com/upstream/fetch.git`,
			PushURL:  `https://github.com/upstream/push.git`,
		},
		`something`: Remote{
			Name:     `something`,
			FetchURL: `[email protected]:something/fetch.git`,
			PushURL:  `[email protected]:something/push.git`,
		},
	}

	assert.Equal(`github.com/upstream/fetch`, guessPrimaryRemote(rs))
	afs := allFetchURLs(rs)
	assert.Contains(afs, `github.com/origin/fetch`)
	assert.NotContains(afs, `github.com/origin/push`)
	assert.Contains(afs, `github.com/upstream/fetch`)
	assert.NotContains(afs, `github.com/upstream/push`)
	assert.Contains(afs, `github.com/something/fetch`)
	assert.NotContains(afs, `github.com/something/push`)

	delete(rs, `upstream`)
	assert.Equal(`github.com/origin/fetch`, guessPrimaryRemote(rs))
	afs = allFetchURLs(rs)
	assert.Contains(afs, `github.com/origin/fetch`)
	assert.NotContains(afs, `github.com/upstream/fetch`)

	delete(rs, `origin`)
	assert.Equal(``, guessPrimaryRemote(rs))
	afs = allFetchURLs(rs)
	assert.NotContains(afs, `github.com/upstream/fetch`)
	assert.Contains(afs, `github.com/something/fetch`)
}
Example #2
0
func TestEphemeralTag(t *testing.T) {
	assert := assert.New(t)

	bc := BuildConfig{
		Tag: "1.2.3",
		Context: &BuildContext{
			Sh: &shell.Sh{},
			Source: SourceContext{
				PrimaryRemoteURL:   "github.com/opentable/present",
				Revision:           "abcd",
				NearestTagName:     "1.2.0",
				NearestTagRevision: "3541",
			},
		},
	}
	/*
		bc := BuildConfig{
			Strict:   true,
			Tag:      "1.2.3",
			Repo:     "github.com/opentable/present",
			Revision: "abcdef",
			Context: &BuildContext{
			Sh: &shell.Sh{},
				Source: SourceContext{
					RemoteURL: "github.com/opentable/present",
					RemoteURLs: []string{
						"github.com/opentable/present",
						"github.com/opentable/also",
					},
					Revision:           "abcdef",
					NearestTagName:     "1.2.3",
					NearestTagRevision: "abcdef",
					Tags: []Tag{
						Tag{Name: "1.2.3"},
					},
				},
			},
		}
	*/

	ctx := bc.NewContext()
	assert.Equal(`1.2.3+abcd`, ctx.Source.Version().Version.String())
	assert.Contains(ctx.Advisories, string(EphemeralTag))
	assert.NotContains(ctx.Advisories, string(TagNotHead))
	assert.NoError(bc.GuardRegister(ctx))
}
Example #3
0
func TestTagNotHead(t *testing.T) {
	assert := assert.New(t)

	bc := BuildConfig{
		Tag: "1.2.3",
		Context: &BuildContext{
			Sh: &shell.Sh{},
			Source: SourceContext{
				Revision:           "abcd",
				NearestTagName:     "1.2.3",
				NearestTagRevision: "def0",
				Tags: []Tag{
					Tag{Name: "1.2.3"},
				},
			},
		},
	}

	ctx := bc.NewContext()
	assert.Equal(`1.2.3+abcd`, ctx.Source.Version().Version.String())
	assert.Contains(ctx.Advisories, string(TagNotHead))
	assert.NotContains(ctx.Advisories, string(EphemeralTag))
}
Example #4
0
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
//    assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
//    assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
//    assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
//
// Returns whether the assertion was successful (true) or not (false).
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
	if !assert.NotContains(t, s, contains, msgAndArgs...) {
		t.FailNow()
	}
}