Namespace is a query param
This commit is contained in:
@@ -53,7 +53,7 @@ func TestWho(t *testing.T) {
|
||||
|
||||
t.Run("get fake", func(t *testing.T) {
|
||||
iwant := want
|
||||
r := httptest.NewRequest(http.MethodGet, "/who/col?id=FAKER"+iwant.Name, nil)
|
||||
r := httptest.NewRequest(http.MethodGet, "/who?namespace=col&id=FAKER"+iwant.Name, nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusNotFound {
|
||||
@@ -63,7 +63,7 @@ func TestWho(t *testing.T) {
|
||||
|
||||
t.Run("get real", func(t *testing.T) {
|
||||
iwant := want
|
||||
r := httptest.NewRequest(http.MethodGet, "/who/col?id="+iwant.Name, nil)
|
||||
r := httptest.NewRequest(http.MethodGet, "/who?namespace=col&id="+iwant.Name, nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -91,7 +91,7 @@ func TestWho(t *testing.T) {
|
||||
|
||||
t.Run("put fake", func(t *testing.T) {
|
||||
iwant := want
|
||||
r := httptest.NewRequest(http.MethodPut, "/who/col?id=FAKER"+iwant.Name, strings.NewReader(`{"title":"this should fail to find someone"}`))
|
||||
r := httptest.NewRequest(http.MethodPut, "/who?namespace=col&id=FAKER"+iwant.Name, strings.NewReader(`{"title":"this should fail to find someone"}`))
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusNotFound {
|
||||
@@ -101,7 +101,7 @@ func TestWho(t *testing.T) {
|
||||
|
||||
t.Run("put real", func(t *testing.T) {
|
||||
iwant := want
|
||||
r := httptest.NewRequest(http.MethodPut, "/who/col?id="+iwant.Name, strings.NewReader(`{"title":"this should work"}`))
|
||||
r := httptest.NewRequest(http.MethodPut, "/who?namespace=col&id="+iwant.Name, strings.NewReader(`{"title":"this should work"}`))
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -124,7 +124,7 @@ func TestWho(t *testing.T) {
|
||||
t.Run("post exists", func(t *testing.T) {
|
||||
iwant := want
|
||||
iwant.Name = ""
|
||||
r := httptest.NewRequest(http.MethodPost, "/who/col?id="+want.Name, strings.NewReader(`{"title":"this should fail to insert"}`))
|
||||
r := httptest.NewRequest(http.MethodPost, "/who?namespace=col&id="+want.Name, strings.NewReader(`{"title":"this should fail to insert"}`))
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusConflict {
|
||||
@@ -139,7 +139,7 @@ func TestWho(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := httptest.NewRequest(http.MethodPost, "/who/col?id=NEWBIE"+want.Name, bytes.NewReader(b))
|
||||
r := httptest.NewRequest(http.MethodPost, "/who?namespace=col&id=NEWBIE"+want.Name, bytes.NewReader(b))
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -160,13 +160,13 @@ func TestWho(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("delete real", func(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodDelete, "/who/col?id=NEWBIE"+want.Name, nil)
|
||||
r := httptest.NewRequest(http.MethodDelete, "/who?namespace=col&id=NEWBIE"+want.Name, nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("%d: %s", w.Code, w.Body.Bytes())
|
||||
}
|
||||
r = httptest.NewRequest(http.MethodGet, "/who/col?id=NEWBIE"+want.Name, nil)
|
||||
r = httptest.NewRequest(http.MethodGet, "/who?namespace=col&id=NEWBIE"+want.Name, nil)
|
||||
w = httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusNotFound {
|
||||
@@ -175,7 +175,7 @@ func TestWho(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("delete fake", func(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodDelete, "/who/col?id=FAKER"+want.Name, nil)
|
||||
r := httptest.NewRequest(http.MethodDelete, "/who?namespace=col&id=FAKER"+want.Name, nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -184,7 +184,7 @@ func TestWho(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("patch fake", func(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodPatch, "/who/col?id=FAKER"+want.Name, nil)
|
||||
r := httptest.NewRequest(http.MethodPatch, "/who?namespace=col&id=FAKER"+want.Name, nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code == http.StatusOK {
|
||||
@@ -201,7 +201,7 @@ func TestWho(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := httptest.NewRequest(http.MethodPatch, "/who/col?id="+want.Name, bytes.NewReader(b))
|
||||
r := httptest.NewRequest(http.MethodPatch, "/who?namespace=col&id="+want.Name, bytes.NewReader(b))
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -222,13 +222,13 @@ func TestWho(t *testing.T) {
|
||||
got.Modified = 0
|
||||
want.Modified = 0
|
||||
if fmt.Sprint(got) != fmt.Sprint(want) {
|
||||
t.Fatalf("withotu connections and modified, got != want: want \n %+v, got \n %+v", want, got)
|
||||
t.Fatalf("without connections and modified, got != want: want \n %+v, got \n %+v", want, got)
|
||||
}
|
||||
t.Logf("%s", w.Body.Bytes())
|
||||
})
|
||||
|
||||
t.Run("trace fake", func(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodTrace, "/who/notcol", nil)
|
||||
r := httptest.NewRequest(http.MethodTrace, "/who?namespace=notcol", nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -237,7 +237,7 @@ func TestWho(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("trace real", func(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodTrace, "/who/col", nil)
|
||||
r := httptest.NewRequest(http.MethodTrace, "/who?namespace=col", nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
|
||||
Reference in New Issue
Block a user