Skip to content

Instantly share code, notes, and snippets.

@theckman
Last active August 29, 2015 14:18
Show Gist options
  • Save theckman/6a5d0cade743aceaa26b to your computer and use it in GitHub Desktop.
Save theckman/6a5d0cade743aceaa26b to your computer and use it in GitHub Desktop.
gocheck dryin' it up
func (t *TestSuite) TestAddTag(c *C) {
c.Assert(len(t.g.Tags), Equals, 0)
t.g.AddTag("test")
c.Assert(len(t.g.Tags), Equals, 1)
c.Check(t.g.Tags[0], Equals, "test")
t.g.AddTag("test2")
t.g.AddTag("test") // verify tags are de-duped
c.Assert(len(t.g.Tags), Equals, 2)
c.Check(t.g.Tags[0], Equals, "test")
c.Check(t.g.Tags[1], Equals, "test2")
}
func TestAddTag(t *testing.T) {
var g *godspeed.Godspeed
g, err := gspdtest.BuildGodspeed(godspeed.DefaultPort, false)
if err != nil {
t.Error(err.Error())
return
}
defer g.Conn.Close()
if len(g.Tags) != 0 {
t.Errorf("tags have already been set on the Godspeed instance: %v", strings.Join(g.Tags, ", "))
return
}
g.AddTag("test")
if len(g.Tags) != 1 || g.Tags[0] != "test" {
t.Errorf("something went wrong adding 'test' tag; current tags: %v", strings.Join(g.Tags, ", "))
}
g.AddTag("test2")
g.AddTag("test") // verify we de-dupe
if len(g.Tags) != 2 || g.Tags[0] != "test" || g.Tags[1] != "test2" {
t.Errorf("something went wrong adding 'test2' tag; current tags: %v", strings.Join(g.Tags, ", "))
}
}
func (t *TestSuite) TestSetNamespace(c *C) {
c.Check(t.g.Namespace, Equals, "")
t.g.SetNamespace("heckman")
c.Check(t.g.Namespace, Equals, "heckman")
}
func TestSetNamespace(t *testing.T) {
var g *godspeed.Godspeed
g, err := gspdtest.BuildGodspeed(godspeed.DefaultPort, false)
if err != nil {
t.Error(err.Error())
return
}
defer g.Conn.Close()
if len(g.Namespace) != 0 {
t.Errorf("namespace has already been set on the Godspeed instance: %v", g.Namespace)
}
g.SetNamespace("heckman")
if g.Namespace != "heckman" {
t.Errorf("failure while trying to set Namespace to 'heckman', is: %v", g.Namespace)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment