f-21: api coherence
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
649ca66bf9
commit
e939467abf
5 changed files with 43 additions and 17 deletions
|
|
@ -81,7 +81,7 @@ func TestPostSubnet_Created(t *testing.T) {
|
|||
|
||||
func TestPostSubnet_MissingFields(t *testing.T) {
|
||||
s, _ := newTestServer(t)
|
||||
body, _ := json.Marshal(SubnetCreateRequest{Name: "sn-1"}) // vpc, iface_type, gateway_ip, cidr manquants
|
||||
body, _ := json.Marshal(SubnetCreateRequest{Name: "sn-1"}) // vpc, gateway_ip, cidr manquants
|
||||
w := httptest.NewRecorder()
|
||||
s.SubnetsHandler(w, httptest.NewRequest(http.MethodPost, "/subnets", bytes.NewReader(body)))
|
||||
if w.Code != http.StatusBadRequest {
|
||||
|
|
@ -89,6 +89,24 @@ func TestPostSubnet_MissingFields(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPostSubnet_IfaceTypeOptional(t *testing.T) {
|
||||
s, db := newTestServer(t)
|
||||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
req := SubnetCreateRequest{
|
||||
Name: "sn-opt",
|
||||
VPC: "vpc-1",
|
||||
GatewayIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
// IfaceType omis — doit utiliser default_interface
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
w := httptest.NewRecorder()
|
||||
s.SubnetsHandler(w, httptest.NewRequest(http.MethodPost, "/subnets", bytes.NewReader(body)))
|
||||
if w.Code != http.StatusAccepted {
|
||||
t.Fatalf("attendu 202, obtenu %d: %s", w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostSubnet_VPCNotFound(t *testing.T) {
|
||||
s, _ := newTestServer(t)
|
||||
req := SubnetCreateRequest{
|
||||
|
|
@ -101,8 +119,8 @@ func TestPostSubnet_VPCNotFound(t *testing.T) {
|
|||
body, _ := json.Marshal(req)
|
||||
w := httptest.NewRecorder()
|
||||
s.SubnetsHandler(w, httptest.NewRequest(http.MethodPost, "/subnets", bytes.NewReader(body)))
|
||||
if w.Code != http.StatusConflict {
|
||||
t.Errorf("attendu 409, obtenu %d", w.Code)
|
||||
if w.Code != http.StatusUnprocessableEntity {
|
||||
t.Errorf("attendu 422, obtenu %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,8 +156,8 @@ func TestPostSubnet_VPCDeleting(t *testing.T) {
|
|||
body, _ := json.Marshal(req)
|
||||
w := httptest.NewRecorder()
|
||||
s.SubnetsHandler(w, httptest.NewRequest(http.MethodPost, "/subnets", bytes.NewReader(body)))
|
||||
if w.Code != http.StatusConflict {
|
||||
t.Errorf("attendu 409, obtenu %d", w.Code)
|
||||
if w.Code != http.StatusUnprocessableEntity {
|
||||
t.Errorf("attendu 422, obtenu %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue