本文整理匯總了Golang中github.com/nyarly/testify/assert.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestNameCache
func TestNameCache(t *testing.T) {
assert := assert.New(t)
sous.Log.Debug.SetOutput(os.Stdout)
ResetSingularity()
defer ResetSingularity()
drc := docker_registry.NewClient()
drc.BecomeFoolishlyTrusting()
db, err := docker.GetDatabase(&docker.DBConfig{
Driver: "sqlite3_sous",
Connection: docker.InMemoryConnection("testnamecache"),
})
if err != nil {
t.Fatal(err)
}
nc := docker.NewNameCache("", drc, db)
repoOne := "https://github.com/opentable/one.git"
manifest(nc, "opentable/one", "test-one", repoOne, "1.1.1")
cn, err := nc.GetCanonicalName(BuildImageName("opentable/one", "1.1.1"))
if err != nil {
assert.FailNow(err.Error())
}
labels, err := drc.LabelsForImageName(cn)
if assert.NoError(err) {
assert.Equal("1.1.1", labels[docker.DockerVersionLabel])
}
}
示例2: TestProductionReady
func TestProductionReady(t *testing.T) {
assert := assert.New(t)
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.Len(ctx.Advisories, 0)
assert.NoError(bc.GuardStrict(ctx))
}
示例3: TestMetadataDockerfile
func TestMetadataDockerfile(t *testing.T) {
assert := assert.New(t)
b := Builder{}
br := sous.BuildResult{
ImageID: "identifier",
Advisories: []string{`something is horribly wrong`},
}
bc := sous.BuildContext{
Source: sous.SourceContext{
OffsetDir: "sub",
RemoteURL: "github.com/opentable/test",
Revision: "abcd",
NearestTagName: "2.3.7",
},
}
mddf, err := ioutil.ReadAll(b.metadataDockerfile(&br, &bc))
assert.NoError(err)
assert.Equal(
`FROM identifier
LABEL \
com.opentable.sous.repo_offset="sub" \
com.opentable.sous.repo_url="github.com/opentable/test" \
com.opentable.sous.revision="abcd" \
com.opentable.sous.version="2.3.7" \
com.opentable.sous.advisories="something is horribly wrong"`, string(mddf))
}
示例4: TestGetRunningDeploymentSet_otherCluster
func TestGetRunningDeploymentSet_otherCluster(t *testing.T) {
//sous.Log.Vomit.SetFlags(sous.Log.Vomit.Flags() | log.Ltime)
//sous.Log.Vomit.SetOutput(os.Stderr)
//sous.Log.Vomit.Print("Starting stderr output")
sous.Log.Debug.SetFlags(sous.Log.Debug.Flags() | log.Ltime)
sous.Log.Debug.SetOutput(os.Stderr)
sous.Log.Debug.Print("Starting stderr output")
assert := assert.New(t)
registerLabelledContainers()
drc := docker_registry.NewClient()
drc.BecomeFoolishlyTrusting()
nc := docker.NewNameCache("", drc, newInMemoryDB("grds"))
client := singularity.NewRectiAgent()
d := singularity.NewDeployer(client)
clusters := []string{"other-cluster"}
ds, which := deploymentWithRepo(clusters, nc, assert, d, "github.com/opentable/docker-grafana")
deps := ds.Snapshot()
if assert.Equal(1, len(deps)) {
grafana := deps[which]
assert.Equal(SingularityURL, grafana.Cluster.BaseURL)
assert.Regexp("^0\\.1", grafana.Resources["cpus"]) // XXX strings and floats...
assert.Regexp("^100\\.", grafana.Resources["memory"]) // XXX strings and floats...
assert.Equal("1", grafana.Resources["ports"]) // XXX strings and floats...
assert.Equal(17, grafana.SourceID.Version.Patch)
assert.Equal("91495f1b1630084e301241100ecf2e775f6b672c", grafana.SourceID.Version.Meta)
assert.Equal(1, grafana.NumInstances)
assert.Equal(sous.ManifestKindService, grafana.Kind)
}
ResetSingularity()
}
示例5: TestInvokeRectifyDryruns
func TestInvokeRectifyDryruns(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
testDryRun := func(which string) (sous.Deployer, sous.Registry) {
exe := justCommand(t, []string{`sous`, `rectify`, `-dry-run`, which, `-repo`, `github.com/somewhere`})
assert.Len(exe.Args, 0)
require.IsType(&SousRectify{}, exe.Cmd)
rect := exe.Cmd.(*SousRectify)
// currently no easy way to tell if the deploy client is live or dummy
return nil, rect.Resolver.Registry
}
_, r := testDryRun("both")
assert.IsType(&sous.DummyRegistry{}, r)
_, r = testDryRun("none")
assert.IsType(&docker.NameCache{}, r)
_, r = testDryRun("scheduler")
assert.IsType(&docker.NameCache{}, r)
_, r = testDryRun("registry")
assert.IsType(&sous.DummyRegistry{}, r)
}
示例6: TestInvokeHarvest
func TestInvokeHarvest(t *testing.T) {
assert := assert.New(t)
exe := justCommand(t, []string{`sous`, `harvest`, `sms-continual-test`})
assert.NotNil(exe)
assert.Len(exe.Args, 1)
}
示例7: TestBuildDeployment
func TestBuildDeployment(t *testing.T) {
assert := assert.New(t)
m := &Manifest{
Source: SourceLocation{},
Owners: []string{"[email protected]"},
Kind: ManifestKindService,
}
sp := DeploySpec{
DeployConfig: DeployConfig{
Resources: Resources{},
Args: []string{},
Env: Env{},
NumInstances: 3,
Volumes: Volumes{
&Volume{"h", "c", "RO"},
},
},
Version: semv.MustParse("1.2.3"),
clusterName: "cluster.name",
}
var ih []DeploySpec
nick := "cn"
state := &State{Defs: Defs{Clusters: Clusters{nick: &Cluster{BaseURL: "http://not"}}}}
d, err := BuildDeployment(state, m, nick, sp, ih)
if assert.NoError(err) {
if assert.Len(d.DeployConfig.Volumes, 1) {
assert.Equal("c", d.DeployConfig.Volumes[0].Container)
}
assert.Equal(nick, d.ClusterName)
}
}
示例8: TestCanMakeAnAgent
func TestCanMakeAnAgent(t *testing.T) {
assert := assert.New(t)
agent, err := NewAgent()
assert.NoError(err)
assert.NotNil(agent)
}
示例9: TestInvokeUpdate
func TestInvokeUpdate(t *testing.T) {
assert := assert.New(t)
exe := justCommand(t, []string{`sous`, `update`})
assert.NotNil(exe)
assert.Len(exe.Args, 0)
}
示例10: TestNewClient
// This test is terrible, but the current design of the client is hard to test
func TestNewClient(t *testing.T) {
assert := assert.New(t)
c := NewClient()
assert.NotNil(c)
c.Cancel()
}
示例11: TestInvokeContext
/*
usage: sous context
context prints out sous's view of your current context
*/
func TestInvokeContext(t *testing.T) {
assert := assert.New(t)
exe := justCommand(t, []string{`sous`, `context`})
assert.NotNil(exe)
assert.Len(exe.Args, 0)
}
示例12: TestModifyScale
func TestModifyScale(t *testing.T) {
log.SetFlags(log.Flags() | log.Lshortfile)
assert := assert.New(t)
mods := make(chan *sous.DeployablePair, 1)
errs := make(chan error, 10)
pair := baseDeployablePair()
pair.Prior.Deployment.DeployConfig.NumInstances = 12
pair.Post.Deployment.DeployConfig.NumInstances = 24
client := sous.NewDummyRectificationClient()
deployer := NewDeployer(client)
mods <- pair
close(mods)
deployer.RectifyModifies(mods, errs)
close(errs)
for e := range errs {
t.Error(e)
}
assert.Len(client.Deployed, 0)
if assert.Len(client.Created, 1) {
assert.Equal(24, client.Created[0].Count)
}
}
示例13: TestModifyResources
func TestModifyResources(t *testing.T) {
assert := assert.New(t)
version := "1.2.3-test"
pair := baseDeployablePair()
pair.Prior.Deployment.SourceID.Version = semv.MustParse(version)
pair.Prior.Deployment.Resources["memory"] = "100"
pair.Post.Deployment.SourceID.Version = semv.MustParse(version)
pair.Post.Deployment.Resources["memory"] = "500"
pair.Post.BuildArtifact.Name = "1.2.3"
mods := make(chan *sous.DeployablePair, 1)
errs := make(chan error, 10)
client := sous.NewDummyRectificationClient()
deployer := NewDeployer(client)
mods <- pair
close(mods)
deployer.RectifyModifies(mods, errs)
close(errs)
for e := range errs {
t.Error(e)
}
assert.Len(client.Created, 0)
if assert.Len(client.Deployed, 1) {
assert.Regexp("1.2.3", client.Deployed[0].ImageName)
assert.Regexp("500", client.Deployed[0].Res["memory"])
}
}
示例14: TestModifyImage
func TestModifyImage(t *testing.T) {
assert := assert.New(t)
sous.Log.Warn.SetOutput(os.Stderr)
Log.Debug.SetOutput(os.Stderr)
before := "1.2.3-test"
after := "2.3.4-new"
pair := baseDeployablePair()
pair.Prior.Deployment.SourceID.Version = semv.MustParse(before)
pair.Post.Deployment.SourceID.Version = semv.MustParse(after)
pair.Post.BuildArtifact.Name = "2.3.4"
mods := make(chan *sous.DeployablePair, 1)
errs := make(chan error, 10)
client := sous.NewDummyRectificationClient()
deployer := NewDeployer(client)
mods <- pair
close(mods)
deployer.RectifyModifies(mods, errs)
close(errs)
for e := range errs {
t.Error(e)
}
assert.Len(client.Created, 0)
if assert.Len(client.Deployed, 1) {
assert.Regexp("2.3.4", client.Deployed[0].ImageName)
}
}
示例15: TestQueryValuesToManifestIDHappyPath
func TestQueryValuesToManifestIDHappyPath(t *testing.T) {
assert := assert.New(t)
pq := func(s string) *QueryValues {
v, _ := url.ParseQuery(s)
return &QueryValues{v}
}
ev := func(x interface{}, e error) error {
return e
}
mid := func(v sous.ManifestID, e error) sous.ManifestID {
return v
}
assert.NoError(ev(manifestIDFromValues(pq("repo=gh1"))))
assert.NoError(ev(manifestIDFromValues(pq("repo=gh1&offset=o1"))))
assert.NoError(ev(manifestIDFromValues(pq("repo=gh1&offset=o1&flavor=f1"))))
assert.Equal(
mid(manifestIDFromValues(pq("repo=gh1"))),
sous.ManifestID{Source: sous.SourceLocation{Repo: "gh1"}})
assert.Equal(
mid(manifestIDFromValues(pq("repo=gh1&offset=o1"))),
sous.ManifestID{Source: sous.SourceLocation{Repo: "gh1", Dir: "o1"}})
assert.Equal(
mid(manifestIDFromValues(pq("repo=gh1&offset=o1&flavor=f1"))),
sous.ManifestID{Source: sous.SourceLocation{Repo: "gh1", Dir: "o1"}, Flavor: "f1"})
}