<commit_before>package handlers

import (
	"github.com/go-martini/martini"
	"github.com/martini-contrib/render"
	"github.com/slogsdon/b/util"
	"net/http"
	"net/http/httptest"
	"testing"
)

func TestAdminIndex(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin", Admin{}.Index)

	r, err := http.NewRequest("GET", "/admin", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 200)
}

func TestAdminPostsIndex(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	util.ConfigPath = "../fixtures/config/app.config"
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin/posts", Admin{}.Posts.Index)

	r, err := http.NewRequest("GET", "/admin/posts", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 200)
}

func TestAdminPostsEdit(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	util.ConfigPath = "../fixtures/config/app.config"
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin/posts/edit/**", Admin{}.Posts.Edit)

	r, err := http.NewRequest("GET", "/admin/posts/edit/2014-04-16-test-post-1.md", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 200)
}<commit_msg>add last test case for admin<commit_after>package handlers

import (
	"github.com/go-martini/martini"
	"github.com/martini-contrib/render"
	"github.com/slogsdon/b/util"
	"net/http"
	"net/http/httptest"
	"testing"
)

func TestAdminIndex(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin", Admin{}.Index)

	r, err := http.NewRequest("GET", "/admin", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 200)
}

func TestAdminPostsIndex(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	util.ConfigPath = "../fixtures/config/app.config"
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin/posts", Admin{}.Posts.Index)

	r, err := http.NewRequest("GET", "/admin/posts", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 200)
}

func TestAdminPostsEdit_fileExists(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	util.ConfigPath = "../fixtures/config/app.config"
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin/posts/edit/**", Admin{}.Posts.Edit)

	r, err := http.NewRequest("GET", "/admin/posts/edit/2014-04-16-test-post-1.md", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 200)
}

func TestAdminPostsEdit_fileNoExists(t *testing.T) {
	recorder := httptest.NewRecorder()
	m := martini.Classic()
	util.ConfigPath = "../fixtures/config/app.config"
	m.Use(render.Renderer(render.Options{
		Directory: "../fixtures/templates",
		Layout:    "admin/layout",
	}))
	m.Get("/admin/posts/edit/**", Admin{}.Posts.Edit)

	r, err := http.NewRequest("GET", "/admin/posts/edit/2014-04-16-non-existing-file.md", nil)
	m.ServeHTTP(recorder, r)

	expect(t, err, nil)
	expect(t, recorder.Code, 404)
}
{'fraction_non_alphanumeric': 0.19397898324339677, 'fraction_numerical': 0.013348480545299631, 'mean_word_length': 4.336363636363636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7112368', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1350, 'n_words': 222}