fix tests that were dependent on default values of config
This commit is contained in:
parent
a9fd1542e9
commit
522cc3d746
|
@ -22,7 +22,14 @@ func postWm(source string, target string) url.Values {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cnf = common.Configure()
|
cnf = &common.Config{
|
||||||
|
BaseURL: "http://localhost:1337/",
|
||||||
|
Port: 1337,
|
||||||
|
Token: "miauwkes",
|
||||||
|
AllowedWebmentionSources: []string{"brainbaking.com"},
|
||||||
|
Blacklist: []string{"youtube.com"},
|
||||||
|
Whitelist: []string{"brainbaking.com"},
|
||||||
|
}
|
||||||
repo db.MentionRepo
|
repo db.MentionRepo
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,7 +53,7 @@ func TestHandleDelete(t *testing.T) {
|
||||||
|
|
||||||
ts := httptest.NewServer(HandleDelete(repo))
|
ts := httptest.NewServer(HandleDelete(repo))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
defer db.Purge()
|
t.Cleanup(db.Purge)
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s?source=%s&target=%s", ts.URL, wm.Source, wm.Target), nil)
|
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s?source=%s&target=%s", ts.URL, wm.Source, wm.Target), nil)
|
||||||
|
@ -60,7 +67,7 @@ func TestHandleDelete(t *testing.T) {
|
||||||
func TestHandlePostWithInvalidUrlsShouldReturnBadRequest(t *testing.T) {
|
func TestHandlePostWithInvalidUrlsShouldReturnBadRequest(t *testing.T) {
|
||||||
ts := httptest.NewServer(HandlePost(cnf, repo))
|
ts := httptest.NewServer(HandlePost(cnf, repo))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
defer db.Purge()
|
t.Cleanup(db.Purge)
|
||||||
|
|
||||||
res, err := http.PostForm(ts.URL, postWm("https://haha.be/woof/said/the/dog.txt", "https://pussies.nl/mycatjustthrewup/gottacleanup.html"))
|
res, err := http.PostForm(ts.URL, postWm("https://haha.be/woof/said/the/dog.txt", "https://pussies.nl/mycatjustthrewup/gottacleanup.html"))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -75,7 +82,7 @@ func TestHandlePostWithInvalidUrlsShouldReturnBadRequest(t *testing.T) {
|
||||||
func TestHandlePostWithTestServer_Parallel(t *testing.T) {
|
func TestHandlePostWithTestServer_Parallel(t *testing.T) {
|
||||||
ts := httptest.NewServer(HandlePost(cnf, repo))
|
ts := httptest.NewServer(HandlePost(cnf, repo))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
defer db.Purge()
|
t.Cleanup(db.Purge)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,16 @@ func buildHttpReq(source string, target string) *httpReqMock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = common.Configure()
|
var (
|
||||||
|
config = &common.Config{
|
||||||
|
BaseURL: "https://somecool.base.url/",
|
||||||
|
Port: 1337,
|
||||||
|
Token: "miauwkes",
|
||||||
|
AllowedWebmentionSources: []string{"brainbaking.com", "jefklakscodex.com"},
|
||||||
|
Blacklist: []string{"youtube.com"},
|
||||||
|
Whitelist: []string{"brainbaking.com"},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
|
Loading…
Reference in New Issue