Ejemplo n.º 1
0
func TestStreamResponsePayload(t *testing.T) {
	response := NewMartiniRecorder()

	martiniApp := App()
	//	GET and immediately close
	response.CloseNotifyC <- true
	request, err := http.NewRequest("GET", "/stream/TestStreamResponsePayload", nil)
	if err != nil {
		t.Fail()
	}
	martiniApp.ServeHTTP(response, request)

	assert.Equals(t, response.Code, http.StatusOK)

	name, payloads := ParsePayload(response.Body)

	assert.Equals(t, name, "uid")

	assert.Equals(t, payloads["type"], "uid")
	assert.Equals(t, payloads["uid"], payloads["from"])
	//	present from and to
	_, ok := payloads["from"]
	assert.Assert(t, ok, "From field missed")
}
Ejemplo n.º 2
0
func TestNewNamesGeneration(t *testing.T) {
	for i := 0; i < 5; i++ {
		var name string = NewName(i)
		assert.Assert(t, name != "", "Expected non empty name")
	}
}
Ejemplo n.º 3
0
func TestNewNamesBasic(t *testing.T) {

	var name string = NewName(0)
	assert.Assert(t, name != "", "Expected non empty name")
}
Ejemplo n.º 4
0
func TestNewNamesCollision(t *testing.T) {

	var name_first string = NewName(0)
	var name_after string = NewName(1)
	assert.Assert(t, name_after != name_first, "Unaccepted name generation")
}