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)
}
func TestSubjectSendingCompletion(t *testing.T) {
	subject := Subject{}
	completed := false

	subject.Subscribe(func(value interface{}) {},
		func() { completed = true },
		func(err error) {})

	subject.SendCompletion()

	assert.True(t, completed)
	assert.True(t, subject.IsStopped())
}
func TestSubjectSendingError(t *testing.T) {
	subject := Subject{}
	failed := false

	subject.Subscribe(func(value interface{}) {},
		func() {},
		func(err error) { failed = true })

	subject.SendError(nil)

	assert.True(t, failed)
	assert.True(t, subject.IsStopped())
}
func TestSubjectNewObservableDisposable(t *testing.T) {
	disposed := false
	observable := NewObservable(func(subject *Subject) Disposable {
		return NewDisposable(func() {
			disposed = true
			assert.True(t, subject.IsDisposed())
		})
	})

	disposable := observable.Subscribe(nil, nil, nil)
	disposable.Dispose()

	assert.True(t, disposed)
}
Beispiel #5
0
func TestContains(t *testing.T) {
	assert.True(t, contains([]string{"a", "b", "c"}, "b"))
	assert.False(t, contains([]string{"a", "b", "c"}, "d"))
	assert.False(t, contains([]string{"a", "b", "c"}, "A"))
	assert.False(t, contains([]string{"a", "b", "c"}, "ab"))
	assert.False(t, contains([]string{}, "d"))
}
Beispiel #6
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))
}
func TestGetConsole(t *testing.T) {
	print("GetConsole\n")
	seedConsole()
	user := gu(t)
	c, err := GetConsole("NES", user)
	if err != nil {
		t.Errorf("GetConsole(NES,1): %s", err)
	}
	assert.Equal(t, 1, c.User.ID, "c.UserID")
	assert.True(t, c.Has, "c.Has")
	assert.True(t, c.HasBox, "c.HasBox")
	assert.True(t, c.HasManual, "c.HasManual")
	assert.Equal(t, 3, c.Rating, "c.Rating")
	assert.Equal(t, "is good", c.Review, "c.Review")
	assert.Equal(t, "Nintendo", c.Manufacturer, "c.Manufacturer")
	assert.False(t, c.Want, "c.Want")
	assert.False(t, c.WantGames, "c.WantGames")
}
func TestEntry_MarkUnread(t *testing.T) {
	e := ef()
	err := e.MarkRead()
	assert.Nil(t, err)
	e = ge()
	assert.False(t, e.Unread)
	err = e.MarkUnread()
	assert.Nil(t, err)
	e = ge()
	assert.True(t, e.Unread)
}
func TestSubjectNewObservable(t *testing.T) {
	observable := NewObservable(func(subject *Subject) Disposable {
		subject.SendCompletion()
		return nil
	})

	completed := false

	observable.Subscribe(func(value interface{}) {},
		func() { completed = true },
		func(err error) {})
	assert.True(t, completed)
}
func TestSubjectSendingNext(t *testing.T) {
	subject := Subject{}
	next := false

	subject.Subscribe(func(value interface{}) { next = true },
		func() {},
		func(err error) {})

	subject.SendNext(nil)

	assert.True(t, next)
	assert.False(t, subject.IsStopped())
}
Beispiel #11
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)
}