コード例 #1
0
ファイル: editor_test.go プロジェクト: fxnn/gone
func TestWriteUnauthorized(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = postRequest(t, "/someFile", "")
	var store = mockstore.New()
	var sut = createSut(store)

	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusUnauthorized)

}
コード例 #2
0
ファイル: editor_test.go プロジェクト: fxnn/gone
func TestCreateUIMissingWritePermission(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?create")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenNotExists()
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusUnauthorized)

}
コード例 #3
0
ファイル: editor_test.go プロジェクト: fxnn/gone
func TestCreateUIAlreadyExists(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?create")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenWriteAccess()
	store.GivenMimeType("text/plain")
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusConflict)

}
コード例 #4
0
ファイル: editor_test.go プロジェクト: fxnn/gone
func TestCreateUISuccess(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?create")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenWriteAccess()
	store.GivenNotExists()
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusOK)

}
コード例 #5
0
ファイル: editor_test.go プロジェクト: fxnn/gone
func TestEditUIMissingWritePermission(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?edit")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenReadAccess()
	store.GivenMimeType("text/plain")
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusUnauthorized)

}
コード例 #6
0
ファイル: editor_test.go プロジェクト: fxnn/gone
func TestWriteSuccess(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = postRequest(t, "/someFile", "")
	var store = mockstore.New()
	var sut = createSut(store)

	request.PostForm.Set("content", "content")
	store.GivenWriteAccess()
	sut.ServeHTTP(response, request)

	assertResponseBody(t, response, "")
	assertResponseCode(t, response, http.StatusFound)
	assertResponseHeader(t, response, "Location", "/someFile?edit")

}