Exemplo n.º 1
0
func TestRemoveAppsMessagesWithMessagesFromOthersRegistered(t *testing.T) {
	setUp()
	a1 := app.NewApp()
	a2 := app.NewApp()
	RecordMsg(a1, "foo")
	RecordMsg(a1, "bar")
	RecordMsg(a2, "baz")
	RecordMsg(a2, "qux")
	RemoveAppsMessages(a1)
	assert.Len(t, appsMessages[a2], 2)
	assert.Equal(t, appsMessages[a2], []string{"baz", "qux"})
	assert.Len(t, msgIdMap, 2)
	assert.Equal(t, msgIdMap["baz"], a2)
}
Exemplo n.º 2
0
// Listens for and accepts a new application connection
// Returns a reference to the App which was accepted
func acceptApp(lnr net.Listener) (*app.App, error) {
	conn, err := lnr.Accept()
	if err != nil {
		return nil, err
	}
	ret := app.NewApp()
	ret.Connection = conn
	return ret, nil
}
Exemplo n.º 3
0
func TestRemoveAppsMessagesWithMessagesRegistered(t *testing.T) {
	setUp()
	a := app.NewApp()
	RecordMsg(a, "foo")
	RecordMsg(a, "bar")
	RemoveAppsMessages(a)
	assert.Len(t, appsMessages, 0)
	assert.Len(t, msgIdMap, 0)
}
Exemplo n.º 4
0
func TestRecordMsgAppendsAppsMessages(t *testing.T) {
	setUp()
	a := app.NewApp()
	id := "something"
	appsMessages[a] = []string{"something_else"}
	RecordMsg(a, id)

	assert.Len(t, appsMessages[a], 2)
}
Exemplo n.º 5
0
func TestRecordMsgCreatesAppsMessagesKey(t *testing.T) {
	setUp()
	a := app.NewApp()
	id := "something"
	RecordMsg(a, id)

	assert.Len(t, appsMessages, 1, "There should be 1 app registered")
	assert.Equal(t, appsMessages[a], []string{id})
}
Exemplo n.º 6
0
func TestRecordMsgAddsToMap(t *testing.T) {
	setUp()
	a := app.NewApp()
	id := "something"
	RecordMsg(a, id)

	assert.Len(t, msgIdMap, 1, "The map should have 1 id")
	assert.Equal(t, msgIdMap[id], a, "The map should have some_id -> a")
}
Exemplo n.º 7
0
func TestRemoveAppsMessagesWithNothingRegistered(t *testing.T) {
	setUp()
	a := app.NewApp()
	assert.NotPanics(t, func() { RemoveAppsMessages(a) })
}