コード例 #1
0
func TestCreateFileRefNoLine(t *testing.T) {
	ref := CreateFileRef("pkg/src/example_item.ft:145", false)
	assert.NotNil(t, ref)
	assert.Equal(t, ref.Path, "pkg/src/example_item.ft")
	assert.Equal(t, ref.Line, 145)
	assert.Equal(t, ref.LineType, RefLineTypeNew)
}
コード例 #2
0
func TestCreateFileRefDeletedLineOverride(t *testing.T) {
	ref := CreateFileRef("pkg/src/example_item.ft:145", true)
	assert.NotNil(t, ref)
	assert.Equal(t, ref.Path, "pkg/src/example_item.ft")
	assert.Equal(t, ref.Line, 145)
	assert.Equal(t, ref.LineType, RefLineTypeOld)
}
コード例 #3
0
func TestCreateFileMultiColon(t *testing.T) {
	ref := CreateFileRef("pkg/src/item:other.txt:98", false)
	assert.NotNil(t, ref)
	assert.Equal(t, ref.Path, "pkg/src/item:other.txt")
	assert.Equal(t, ref.Line, 98)
	assert.Equal(t, ref.LineType, RefLineTypeNew)
}
コード例 #4
0
ファイル: game_test.go プロジェクト: ChrisKaufmann/gameslist
func TestGetAllWantedGames(t *testing.T) {
	print("GetAllWantedGames\n")
	seedGame()
	user := gu(t)
	c, err := GetConsole("Atari 2600", user)
	assert.Nil(t, err, "GetConsole(Atari 2600,user)")
	c2, err := GetConsole("NES", user)
	assert.Nil(t, err, "GetConsole(NES,user)")
	print("\tInitial\n")
	wg, err := GetAllWantedGames()
	assert.Nil(t, err, "GetAllWantedGames()")
	assert.Equal(t, 0, len(wg), "GetAllWantedGames")

	print("\tMarking individual games\n")
	g, err := GetGame(1, user)
	assert.Nil(t, err, "GetGame(1,user)")
	g.Want = true
	err = g.Save()
	assert.Nil(t, err, "g.Save()")
	wg, err = GetAllWantedGames()
	assert.Nil(t, err, "GetAllWantedGames()")
	assert.Equal(t, 1, len(wg), "GetAllWantedGames()")

	print("\tMarking Console WantGames\n")
	c.WantGames = true
	err = c.Save()
	assert.Nil(t, err, "c.Save()")
	c2.WantGames = true
	err = c2.Save()
	assert.Nil(t, err, "c2.Save()")
	wg, err = GetAllWantedGames()
	assert.Nil(t, err, "GetAllWantedGames()")
	assert.Equal(t, 1321, len(wg), "GetAllWantedGames()")

}
コード例 #5
0
func TestCreateFileNoLine(t *testing.T) {
	ref := CreateFileRef("pkg/src/item:other.txt", false)
	assert.NotNil(t, ref)
	assert.Equal(t, ref.Path, "pkg/src/item:other.txt")
	assert.Equal(t, ref.Line, 0)
	assert.Equal(t, ref.LineType, RefLineTypeNew)
}
コード例 #6
0
func TestAllMarkedEntries(t *testing.T) {
	e := ef()
	assert.Equal(t, 0, len(AllMarkedEntries("test")))
	err := e.Mark()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(AllMarkedEntries("test")))
}
コード例 #7
0
func TestPropertiesFromBlob(t *testing.T) {
	content := "fruit Green Apple\ntree_type Redwood\n\nThe Redwood is the tallest tree in North America"
	blob := CreatePropertyBlob(content)
	fruit := blob.Get("fruit")
	tree := blob.Get("tree_type")
	assert.Equal(t, "Green Apple", *fruit)
	assert.Equal(t, "Redwood", *tree)
}
コード例 #8
0
func TestCreatePersonFromSpacedNameEmailTime(t *testing.T) {
	p, err := CreatePerson("Carrie Ann McBean <*****@*****.**>").Dematerialize()
	assert.Nil(t, err)
	person := p.(*Person)
	assert.NotNil(t, person)
	assert.Equal(t, person.Email, "*****@*****.**")
	assert.Equal(t, person.Name, "Carrie Ann McBean")
}
コード例 #9
0
func TestCategory_Excludes(t *testing.T) {
	seed()
	c1 := GetCat("1")
	assert.Equal(t, 0, len(c1.Excludes()))
	c1.Exclude = "a,b,c,d,"
	c1.Save()
	assert.Equal(t, 4, len(c1.Excludes()))
}
コード例 #10
0
ファイル: game_test.go プロジェクト: ChrisKaufmann/gameslist
func TestFilter_Manual(t *testing.T) {
	print("Filter_Manual\n")
	c := gsc(t)
	gl, err := c.Games()
	assert.Nil(t, err, "c.Games()")
	assert.Equal(t, 1, len(Filter(gl).Manual(true)), "FilterManual(true)")
	assert.Equal(t, 800, len(Filter(gl).Manual(false)), "FilterManual(false)")
}
コード例 #11
0
func TestCreatePersonFromNameEmailTime(t *testing.T) {
	p, err := CreatePerson("Carrie <*****@*****.**> 1437612685 -0700").Dematerialize()
	assert.Nil(t, err)
	person := p.(*Person)
	assert.NotNil(t, person)
	assert.Equal(t, person.Email, "*****@*****.**")
	assert.Equal(t, person.Name, "Carrie")
}
コード例 #12
0
func TestCreatePersonWithoutName(t *testing.T) {
	p, err := CreatePerson("<*****@*****.**>").Dematerialize()
	assert.Nil(t, err)
	person := p.(*Person)
	assert.NotNil(t, person)
	assert.Equal(t, person.Email, "*****@*****.**")
	assert.Equal(t, person.Name, "")
}
コード例 #13
0
func TestNewCommentAuthor(t *testing.T) {
	author := &Person{"Sam Wafers", "<*****@*****.**>", time.Now(), "-0600"}
	c, err := NewComment("Curious decision here.", "123", nil, author).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, comment.Author, author)
	assert.Equal(t, comment.Amender, author)
}
コード例 #14
0
func TestGetCategories(t *testing.T) {
	seed()
	assert.Equal(t, 4, len(GetCategories("test")))
	var newcat Category
	newcat.Name = "newest!"
	newcat.UserName = "******"
	newcat.Insert("test")
	assert.Equal(t, 5, len(GetCategories("test")))
}
コード例 #15
0
func TestCategory_ReadEntries(t *testing.T) {
	seed()
	c1 := GetCat("1")
	assert.Equal(t, 0, len(c1.ReadEntries()))
	e1 := GetEntry("1", "test")
	err := e1.MarkRead()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(c1.ReadEntries()))
}
コード例 #16
0
func TestCategory_DeleteExcludes(t *testing.T) {
	seed()
	c1 := GetCat("1")
	c1.DeleteExcludes()
	assert.Equal(t, 4, c1.Unread())
	c1.Exclude = "asdf"
	c1.DeleteExcludes()
	assert.Equal(t, 2, c1.Unread())
}
コード例 #17
0
func TestCategory_FeedsStr(t *testing.T) {
	seed()
	c1 := GetCat("1")
	assert.Equal(t, 2, len(c1.FeedsStr()))
	f4, err := GetFeed(4)
	assert.Nil(t, err)
	f4.CategoryID = 1
	f4.Save()
	assert.Equal(t, 3, len(c1.FeedsStr()))
}
コード例 #18
0
func TestNewCommentTime(t *testing.T) {
	var unix int64 = 1433220431
	c, err := NewComment("ELI5?", "123", nil, &Person{Date: time.Unix(unix, 0)}).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment.Author)
	assert.Equal(t, comment.Author.Date.Unix(), unix)
	assert.NotNil(t, comment.Amender)
	assert.Equal(t, comment.Amender.Date, comment.Author.Date)
}
コード例 #19
0
func TestEntry_AutoscrollPX(t *testing.T) {
	e := ef()
	assert.Equal(t, 0, e.AutoscrollPX())
	f, err := GetFeed(1)
	assert.Nil(t, err)
	f.AutoscrollPX = 1234
	err = f.Save()
	assert.Nil(t, err)
	assert.Equal(t, 1234, e.AutoscrollPX())
}
コード例 #20
0
func TestEntry_ViewMode(t *testing.T) {
	e := ef()
	assert.Equal(t, "default", e.ViewMode(), "initial entry.ViewMode")
	f, err := GetFeed(1)
	assert.Nil(t, err, "GetFeed(1)")
	f.ViewMode = "link"
	err = f.Save()
	assert.Nil(t, err)
	assert.Equal(t, "link", e.ViewMode())
}
コード例 #21
0
func TestEntry_UnMark(t *testing.T) {
	e := ef()
	err := e.Mark()
	assert.Nil(t, err)
	e = ge()
	assert.Equal(t, "1", e.Marked)
	err = e.UnMark()
	assert.Nil(t, err)
	e = ge()
	assert.Equal(t, "0", e.Marked)
}
コード例 #22
0
func TestCategory_SearchTitles(t *testing.T) {
	seed()
	c1 := GetCat("1")
	assert.Equal(t, 2, len(c1.SearchTitles("asdf", "unread")))
	assert.Equal(t, 2, len(c1.SearchTitles("asdf", "all")))
	e1 := GetEntry("1", "test")
	err := e1.MarkRead()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(c1.SearchTitles("asdf", "read")))
	err = e1.Mark()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(c1.SearchTitles("asdf", "marked")))
}
コード例 #23
0
func TestCategory_GetAllCategories(t *testing.T) {
	seed()
	assert.Equal(t, 8, cl())
	var cn Category
	cn.Name = "newcat"
	cn.Insert("test")
	assert.Equal(t, 9, cl())
	c1 := GetCat("1")
	c1.Delete()
	c2 := GetCat("2")
	c2.Delete()
	assert.Equal(t, 7, cl())
}
コード例 #24
0
func TestDeserializeComment(t *testing.T) {
	author := &Person{"Morpheus", "*****@*****.**", time.Unix(1437498360, 0), "-0600"}
	c, _ := NewComment("Pick one", "afdafdafd", DeserializeFileRef("bin/exec:15"), author).Dematerialize()
	comment := c.(*Comment)
	newC, err := DeserializeComment(comment.Serialize()).Dematerialize()
	newComment := newC.(*Comment)
	assert.Nil(t, err)
	assert.Equal(t, *comment.Commit, *newComment.Commit)
	assert.Equal(t, *comment.FileRef, *newComment.FileRef)
	assert.Equal(t, *comment.Author, *newComment.Author)
	assert.Equal(t, *comment.Amender, *newComment.Amender)
	assert.Equal(t, comment.Content, newComment.Content)
}
コード例 #25
0
ファイル: result_test.go プロジェクト: kylef/result.go
func TestCombineAllSuccess(t *testing.T) {
  results := []Result{NewSuccess("item1"), NewSuccess("item2"), NewSuccess("item3")}
  transform := func(values ...interface{}) Result {
    return NewSuccess(values)
  }

  result := Combine(transform, results...)

  value := result.Success.([]interface{})
  assert.Equal(t, len(value), 3)
  for index, item := range value {
    assert.Equal(t, item, fmt.Sprintf("item%d", index+1))
  }
}
コード例 #26
0
func TestEntry_ToggleMark(t *testing.T) {
	e := ef()
	nm, err := e.ToggleMark()
	assert.Nil(t, err)
	assert.Equal(t, "set", nm)
	e = ge()
	assert.Equal(t, "1", e.Marked)
	assert.Nil(t, err)
	nm, err = e.ToggleMark()
	assert.Equal(t, "unset", nm)
	assert.Nil(t, err)
	e = ge()
	assert.Equal(t, "0", e.Marked)
}
コード例 #27
0
func TestNewlinesInMessage(t *testing.T) {
	props := "author Elira <*****@*****.**>\nfile src/example.txt\n\n"
	message := "I have a few questions.\nHow do we plan on handling the latter case?\n\nWhere can I get some chili dogs?"
	content := strings.Join([]string{props, message}, "")
	blob := CreatePropertyBlob(content)
	assert.Equal(t, message, blob.Message)
}
コード例 #28
0
func TestNewCommentContent(t *testing.T) {
	c, err := NewComment("Season the chex mix", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, comment.Content, "Season the chex mix")
}
コード例 #29
0
func TestConsole_CheapestGame(t *testing.T) {
	print("Console.CheapestGame\n")
	seedConsole()
	user, err := auth.GetUser(1)
	if err != nil {
		t.Errorf("GetUser(1): %s", err)
	}
	c, err := GetConsole("NES", user)
	assert.Nil(t, err, "GetConsole(NES,user)")
	c.WantGames = true
	c.Save()
	p := 1.01
	gl, err := c.WantedGames()
	fmt.Printf("len(wantedgames): %v\n", len(gl))
	assert.Nil(t, err, "c.Games()")
	for _, g := range gl {
		g.EbayPrice = p
		g.Want = true
		p = p + 1.01
		g.EbayEnds = "2999-01-01 01:00:00"
		err := g.Save()
		assert.Nil(t, err, "g.Save()")
	}

	d, err := GetConsole("NES", user)
	if err != nil {
		t.Errorf("GetConsole(NES,user): %s", err)
	}
	g := d.CheapestGame()
	assert.Equal(t, 1.01, g.EbayPrice, "EbayPrice")
	fmt.Printf("%s, %.2v\n", g.Name, g.EbayPrice)
}
コード例 #30
0
ファイル: user_test.go プロジェクト: ChrisKaufmann/goauth
func TestAllUsers(t *testing.T) {
	initTest(t)
	print("AllUsers\n")
	ul, err := AllUsers()
	assert.Nil(t, err, "AllUsers()")
	assert.Equal(t, len(ul), 12, "len(AllUsers())")
}