This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee3a627
commit e5ab4e6
Showing
2 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1055,6 +1055,112 @@ func TestMutations(t *testing.T) { | |
return m | ||
}(), | ||
}, | ||
"organizationUpdate/without_complement": testCase{ | ||
token: dToken, | ||
mutation: `mutation { | ||
viewer { | ||
organizationUpdate(input: { | ||
name: "new name", | ||
address: { | ||
withoutComplement: true | ||
} | ||
}) { | ||
organization { | ||
name, address {complement} | ||
} | ||
} | ||
} | ||
}`, | ||
response: `{"data":{"viewer":{"organizationUpdate":{"organization":{ | ||
"name": "new name", "address" : {"complement": null} | ||
}}}}}`, | ||
orgRepoMock: func() *orgRepoMock { | ||
m := &orgRepoMock{} | ||
m.On("Get", int64(1)).Once(). | ||
Return( | ||
&model.Organization{ | ||
User: model.User{ | ||
ID: 1, | ||
Email: "[email protected]", | ||
}, | ||
Name: "old name", | ||
About: "old about", | ||
Phone: "", | ||
Video: "http://video.com/wv", | ||
Address: model.Address{ | ||
Street: "Rua Algum Lugar", | ||
Number: "500", | ||
Neighborhood: "Algum Bairro Antigo", | ||
City: "Curitiba", | ||
State: "PR", | ||
Zipcode: "90230000", | ||
Complement: nulls.NewString("Perto do Obelisco"), | ||
}, | ||
}, | ||
nil, | ||
) | ||
|
||
oUpdated := model.Organization{ | ||
User: model.User{ | ||
ID: 1, | ||
Email: "[email protected]", | ||
}, | ||
Name: "new name", | ||
About: "old about", | ||
Phone: "", | ||
Video: "http://video.com/wv", | ||
Address: model.Address{ | ||
Street: "Rua Algum Lugar", | ||
Number: "500", | ||
Neighborhood: "Algum Bairro Antigo", | ||
City: "Curitiba", | ||
State: "PR", | ||
Zipcode: "90230000", | ||
Complement: nulls.String{Valid: false}, | ||
}, | ||
} | ||
|
||
m.On("Update", oUpdated).Once(). | ||
Return(oUpdated, nil) | ||
|
||
return m | ||
}(), | ||
}, | ||
"organizationUpdate/fails_when_withoutComplement_and_complement": testCase{ | ||
token: dToken, | ||
mutation: `mutation { | ||
viewer { | ||
organizationUpdate(input: { | ||
name: "new name", | ||
address: { | ||
withoutComplement: true, | ||
complement: "Olhe para cima" | ||
} | ||
}) { | ||
organization { | ||
name, address {complement} | ||
} | ||
} | ||
} | ||
}`, | ||
response: `{"data":{"viewer":{"organizationUpdate": null }}, "errors": [ | ||
{ "message": "parameters withoutComplement and complement can't be used together", "locations":[] } | ||
]}`, | ||
orgRepoMock: func() *orgRepoMock { | ||
m := &orgRepoMock{} | ||
m.On("Get", int64(1)).Once(). | ||
Return( | ||
&model.Organization{ | ||
User: model.User{ | ||
ID: 1, | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
nil, | ||
) | ||
return m | ||
}(), | ||
}, | ||
} | ||
|
||
for name, test := range tests { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters