Example #1
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)
}
Example #2
0
func TestNewCommentCommit(t *testing.T) {
	c, err := NewComment("Wat?", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, *comment.Commit, "abcdefg")
}
Example #3
0
func TestCompareVersionsRepoCorrupted(t *testing.T) {
	status, err := compareVersion("1.4.5", "2.0").Dematerialize()
	assert.NotNil(t, err)
	assert.True(t, strings.Contains(err.Error(), "1.4.5"))
	assert.True(t, strings.Contains(err.Error(), "2.0"))
	assert.Nil(t, status)
}
Example #4
0
func TestNewCommentID(t *testing.T) {
	c, err := NewComment("This behavior is undocumented", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Nil(t, comment.ID)
}
Example #5
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)
}
Example #6
0
func TestNewCommentDeleted(t *testing.T) {
	c, err := NewComment("What is happening here?", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.False(t, comment.Deleted)
}
Example #7
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)
}
func TestCategory_ClearCache(t *testing.T) {
	seed()
	var c Category
	var cc int
	err := mc.Get("Category1_", &c)
	if err == nil {
		t.Errorf("mc.Get(Category1_) did not error")
	}
	err = mc.Get("Category1_UnreadCount", &cc)
	if err == nil {
		t.Errorf("mc.Get(Category1_UnreadCount) did not error")
	}
	CacheAllCats()
	err = mc.Get("Category1_", &c)
	if err != nil {
		t.Errorf("mc.Get(Category1_): %s", err)
	}
	err = mc.Get("Category1_UnreadCount", &cc)
	if err != nil {
		t.Errorf("mc.Get(Category1_UnreadCount): %s", err)
	}
	c.ClearCache()
	err = mc.Get("Category1_", &c)
	if err == nil {
		t.Errorf("mc.Get(Category1_) did not error")
	}
	err = mc.Get("Category1_UnreadCount", &cc)
	assert.NotNil(t, err)
	if err == nil {
		t.Errorf("mc.Get(Category1_UnreadCount) did not error")
	}

}
Example #9
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)
}
Example #10
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")
}
Example #11
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)
}
Example #12
0
func TestNewCommentAmender(t *testing.T) {
	author := &Person{"Sam Wafers", "<*****@*****.**>", time.Now(), "-0600"}
	c, err := NewComment("Doesn't this violate the laws of physics?", "123", nil, author).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, comment.Amender, author)
}
Example #13
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")
}
Example #14
0
func TestSerializePersonEmailOnly(t *testing.T) {
	data := "<*****@*****.**>"
	p, err := CreatePerson(data).Dematerialize()
	assert.Nil(t, err)
	assert.NotNil(t, p)
	person := p.(*Person)
	assert.True(t, strings.Contains(person.Serialize(), data))
}
Example #15
0
func TestSerializePersonFull(t *testing.T) {
	data := "Katie Em <*****@*****.**> 1437498360 +0400"
	p, err := CreatePerson(data).Dematerialize()
	assert.Nil(t, err)
	assert.NotNil(t, p)
	person := p.(*Person)
	assert.Equal(t, person.Serialize(), data)
}
Example #16
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, "")
}
Example #17
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")
}
Example #18
0
func TestNewCommentFileRef(t *testing.T) {
	ref := &FileRef{"src/example.c", 12, RefLineTypeNew}
	c, err := NewComment("This should be more modular", "abcdefg", ref, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, comment.FileRef, ref)
}
Example #19
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)
}
Example #20
0
func TestCreateEmptyPerson(t *testing.T) {
	_, err := CreatePerson("").Dematerialize()
	assert.NotNil(t, err)
}
Example #21
0
func TestSerializePersonNameOnly(t *testing.T) {
	data := "Katie Em"
	_, err := CreatePerson(data).Dematerialize()
	assert.NotNil(t, err)
}
Example #22
0
func TestCompareVersionsToolNewer(t *testing.T) {
	status, err := compareVersion("2.1.1", "2.1.0").Dematerialize()
	assert.NotNil(t, err)
	assert.True(t, strings.Contains(err.Error(), "git-comment --update"))
	assert.Nil(t, status)
}
Example #23
0
func TestCreateWithoutContent(t *testing.T) {
	_, err := NewComment("", "azerty", new(FileRef), new(Person)).Dematerialize()
	assert.NotNil(t, err)
}
Example #24
0
func TestCompareVersionsRepoNewer(t *testing.T) {
	status, err := compareVersion("2.0.1", "2.1.0").Dematerialize()
	assert.NotNil(t, err)
	assert.Nil(t, status)
}
Example #25
0
func TestCreatePersonFromInvalidEmail(t *testing.T) {
	_, err := CreatePerson("Carrie Ann McBean <carrie.mcbean>").Dematerialize()
	assert.NotNil(t, err)
}