当前位置: 首页>>代码示例>>Golang>>正文


Golang Buildfile.String方法代码示例

本文整理汇总了Golang中github.com/voxxit/drone/shared/build/buildfile.Buildfile.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Buildfile.String方法的具体用法?Golang Buildfile.String怎么用?Golang Buildfile.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/voxxit/drone/shared/build/buildfile.Buildfile的用法示例。


在下文中一共展示了Buildfile.String方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Test_Deis

func Test_Deis(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("Deis Deploy", func() {

		g.It("Should set git.config", func() {
			b := new(buildfile.Buildfile)
			h := Deis{
				App:     "drone",
				Deisurl: "deis.yourdomain.com:2222",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, CmdRevParse)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalUser)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalEmail)).Equal(true)
		})

		g.It("Should add remote", func() {
			b := new(buildfile.Buildfile)
			h := Deis{
				App:     "drone",
				Deisurl: "deis.yourdomain.com:2222/",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit remote add deis ssh://[email protected]:2222/drone.git\n")).Equal(true)
		})

		g.It("Should push to remote", func() {
			b := new(buildfile.Buildfile)
			d := Deis{
				App: "drone",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit push deis $COMMIT:master\n")).Equal(true)
		})

		g.It("Should force push to remote", func() {
			b := new(buildfile.Buildfile)
			h := Deis{
				Force: true,
				App:   "drone",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit add -A\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit commit -m 'adding build artifacts'\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit push deis HEAD:master --force\n")).Equal(true)
		})

	})
}
开发者ID:voxxit,项目名称:drone,代码行数:58,代码来源:deis_test.go

示例2: Test_Tsuru

func Test_Tsuru(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("Tsuru Deploy", func() {

		g.It("Should set git.config", func() {
			b := new(buildfile.Buildfile)
			d := Tsuru{
				Remote: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, CmdRevParse)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalUser)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalEmail)).Equal(true)
		})

		g.It("Should add remote", func() {
			b := new(buildfile.Buildfile)
			d := Tsuru{
				Remote: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit remote add tsuru git://foo.com/bar/baz.git\n")).Equal(true)
		})

		g.It("Should push to remote", func() {
			b := new(buildfile.Buildfile)
			d := Tsuru{
				Remote: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit push tsuru $COMMIT:master\n")).Equal(true)
		})

		g.It("Should force push to remote", func() {
			b := new(buildfile.Buildfile)
			d := Tsuru{
				Force:  true,
				Remote: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit add -A\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit commit -m 'adding build artifacts'\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit push tsuru HEAD:master --force\n")).Equal(true)
		})

	})
}
开发者ID:voxxit,项目名称:drone,代码行数:56,代码来源:tsuru_test.go

示例3: Test_Modulus

func Test_Modulus(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("Modulus Deploy", func() {

		g.It("Requires a Project name", func() {
			b := new(buildfile.Buildfile)
			m := Modulus{
				Project: "foo",
			}

			m.Write(b)
			g.Assert(b.String()).Equal("")
		})

		g.It("Requires a Token", func() {
			b := new(buildfile.Buildfile)
			m := Modulus{
				Token: "bar",
			}

			m.Write(b)
			g.Assert(b.String()).Equal("")
		})

		g.It("Should execute deploy commands", func() {
			b := new(buildfile.Buildfile)
			m := Modulus{
				Project: "foo",
				Token:   "bar",
			}

			m.Write(b)
			g.Assert(b.String()).Equal(`export MODULUS_TOKEN="bar"
[ -f /usr/bin/npm ] || echo ERROR: npm is required for modulus.io deployments
[ -f /usr/bin/npm ] || exit 1
[ -f /usr/bin/sudo ] || npm install -g modulus
[ -f /usr/bin/sudo ] && sudo npm install -g modulus
echo '#DRONE:6d6f64756c7573206465706c6f79202d702022666f6f22'
modulus deploy -p "foo"
`)
		})
	})
}
开发者ID:voxxit,项目名称:drone,代码行数:44,代码来源:modulus_test.go

示例4: Test_Modulus

func Test_Modulus(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("Nodejitsu Deploy", func() {

		g.It("Requires a User", func() {
			b := new(buildfile.Buildfile)
			n := Nodejitsu{
				User: "foo",
			}

			n.Write(b)
			g.Assert(b.String()).Equal("")
		})

		g.It("Requires a Token", func() {
			b := new(buildfile.Buildfile)
			n := Nodejitsu{
				Token: "bar",
			}

			n.Write(b)
			g.Assert(b.String()).Equal("")
		})

		g.It("Should execute deploy commands", func() {
			b := new(buildfile.Buildfile)
			n := Nodejitsu{
				User:  "foo",
				Token: "bar",
			}

			n.Write(b)
			g.Assert(b.String()).Equal(`export username="foo"
export apiToken="bar"
[ -f /usr/bin/sudo ] || npm install -g jitsu
[ -f /usr/bin/sudo ] && sudo npm install -g jitsu
echo '#DRONE:6a69747375206465706c6f79'
jitsu deploy
`)
		})
	})
}
开发者ID:voxxit,项目名称:drone,代码行数:43,代码来源:nodejitsu_test.go

示例5: Test_Heroku

func Test_Heroku(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("Heroku Deploy", func() {

		g.It("Should set git.config", func() {
			b := new(buildfile.Buildfile)
			h := Heroku{
				App: "drone",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, CmdRevParse)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalUser)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalEmail)).Equal(true)
		})

		g.It("Should write token", func() {
			b := new(buildfile.Buildfile)
			h := Heroku{
				App:   "drone",
				Token: "mock-token",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\necho 'machine git.heroku.com login _ password mock-token' >> ~/.netrc\n")).Equal(true)
		})

		g.It("Should add remote", func() {
			b := new(buildfile.Buildfile)
			h := Heroku{
				App: "drone",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit remote add heroku https://git.heroku.com/drone.git\n")).Equal(true)
		})

		g.It("Should push to remote", func() {
			b := new(buildfile.Buildfile)
			d := Heroku{
				App: "drone",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit push heroku $COMMIT:refs/heads/master\n")).Equal(true)
		})

		g.It("Should force push to remote", func() {
			b := new(buildfile.Buildfile)
			h := Heroku{
				Force: true,
				App:   "drone",
			}

			h.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit add -A\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit commit -m 'adding build artifacts'\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit push heroku HEAD:refs/heads/master --force\n")).Equal(true)
		})

	})
}
开发者ID:voxxit,项目名称:drone,代码行数:68,代码来源:heroku_test.go

示例6: Test_Git

func Test_Git(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("Git Deploy", func() {

		g.It("Should set git.config", func() {
			b := new(buildfile.Buildfile)
			d := Git{
				Target: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, CmdRevParse)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalUser)).Equal(true)
			g.Assert(strings.Contains(out, CmdGlobalEmail)).Equal(true)
		})

		g.It("Should add remote", func() {
			b := new(buildfile.Buildfile)
			d := Git{
				Target: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit remote add deploy git://foo.com/bar/baz.git\n")).Equal(true)
		})

		g.It("Should push to remote", func() {
			b := new(buildfile.Buildfile)
			d := Git{
				Target: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit push deploy $COMMIT:master\n")).Equal(true)
		})

		g.It("Should push to alternate branch", func() {
			b := new(buildfile.Buildfile)
			d := Git{
				Branch: "foo",
				Target: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit push deploy $COMMIT:foo\n")).Equal(true)
		})

		g.It("Should force push to remote", func() {
			b := new(buildfile.Buildfile)
			d := Git{
				Force:  true,
				Target: "git://foo.com/bar/baz.git",
			}

			d.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "\ngit add -A\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit commit -m 'add build artifacts'\n")).Equal(true)
			g.Assert(strings.Contains(out, "\ngit push deploy HEAD:master --force\n")).Equal(true)
		})

	})
}
开发者ID:voxxit,项目名称:drone,代码行数:68,代码来源:git_test.go

示例7: Test_NPM

func Test_NPM(t *testing.T) {

	g := goblin.Goblin(t)
	g.Describe("NPM Publish", func() {

		g.BeforeEach(func() {
			var user, pass, email = "", "", ""
			DefaultEmail = &user
			DefaultUser = &pass
			DefaultPass = &email
		})

		g.It("Should run publish", func() {
			b := new(buildfile.Buildfile)
			n := NPM{
				Email:    "[email protected]",
				Username: "foo",
				Password: "bar",
				Folder:   "/path/to/repo",
			}

			n.Write(b)
			out := b.String()
			g.Assert(strings.Contains(out, "npm publish /path/to/repo\n")).Equal(true)
			g.Assert(strings.Contains(out, "\nnpm set")).Equal(false)
			g.Assert(strings.Contains(out, "\nnpm config set")).Equal(false)
		})

		g.It("Should use current directory if folder is empty", func() {
			b := new(buildfile.Buildfile)
			n := NPM{
				Email:    "[email protected]",
				Username: "foo",
				Password: "bar",
			}

			n.Write(b)
			g.Assert(strings.Contains(b.String(), "npm publish .\n")).Equal(true)
		})

		g.It("Should set tag", func() {
			b := new(buildfile.Buildfile)
			n := NPM{
				Email:    "[email protected]ar.com",
				Username: "foo",
				Password: "bar",
				Folder:   "/path/to/repo",
				Tag:      "1.0.0",
			}

			n.Write(b)
			g.Assert(strings.Contains(b.String(), "\n_NPM_PACKAGE_TAG=\"1.0.0\"\n")).Equal(true)
			g.Assert(strings.Contains(b.String(), "npm tag ${_NPM_PACKAGE_NAME} ${_NPM_PACKAGE_TAG}\n")).Equal(true)
		})

		g.It("Should set registry", func() {
			b := new(buildfile.Buildfile)
			n := NPM{
				Email:    "[email protected]",
				Username: "foo",
				Password: "bar",
				Folder:   "/path/to/repo",
				Registry: "https://npmjs.com",
			}

			n.Write(b)
			g.Assert(strings.Contains(b.String(), "\nnpm config set registry https://npmjs.com\n")).Equal(true)
		})

		g.It("Should set always-auth", func() {
			b := new(buildfile.Buildfile)
			n := NPM{
				Email:      "[email protected]",
				Username:   "foo",
				Password:   "bar",
				Folder:     "/path/to/repo",
				AlwaysAuth: true,
			}

			n.Write(b)
			g.Assert(strings.Contains(b.String(), CmdAlwaysAuth)).Equal(true)
		})

		g.It("Should skip when no username or password", func() {
			b := new(buildfile.Buildfile)
			n := new(NPM)

			n.Write(b)
			g.Assert(b.String()).Equal("")
		})

		g.It("Should use default username or password", func() {
			b := new(buildfile.Buildfile)
			n := new(NPM)

			expected := `cat <<EOF > ~/.npmrc
_auth = $(echo "foo:bar" | tr -d "\r\n" | base64)
email = [email protected]
EOF`

//.........这里部分代码省略.........
开发者ID:voxxit,项目名称:drone,代码行数:101,代码来源:npm_test.go


注:本文中的github.com/voxxit/drone/shared/build/buildfile.Buildfile.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。