Spaces test support #4

Merged
merged 6 commits into from Feb 15, 2016

Conversation

Projects
None yet
3 participants
Contributor

voidspace commented Feb 15, 2016

Add a NewSpace method to the test server and test spaces support.

+ server.spaces[server.nextSpace] = newSpace
+ server.spaceNameToID[newSpace.Name] = newSpace.ID
+
+ server.nextSpace++
@dimitern

dimitern Feb 15, 2016

Contributor

FWIW, this is not goroutine-safe - calling NewSpace() concurrently won't work (same applies to nextSubnet). We should fix all those, but it can wait I guess.

testservice_spaces.go
@@ -54,10 +55,11 @@ func spacesHandler(server *TestServer, w http.ResponseWriter, r *http.Request) {
}
if r.URL.Path == spacesURL {
- var spaces []Space
+ var spaces []*Space
for i := uint(1); i < server.nextSpace; i++ {
@dimitern

dimitern Feb 15, 2016

Contributor

This seems surprising - why not for spaceID, space := range server.spaces { .. } ?

@voidspace

voidspace Feb 15, 2016

Contributor

This preserves numerical order by id rather than dictionary iteration order.

Contributor

dimitern commented Feb 15, 2016

LGTM

Contributor

voidspace commented Feb 15, 2016

$$merge$$

Contributor

jujubot commented Feb 15, 2016

jujubot added a commit that referenced this pull request Feb 15, 2016

Merge pull request #4 from voidspace/spaces-test-support
Spaces test support

Add a NewSpace method to the test server and test spaces support.

@jujubot jujubot merged commit f3be5f3 into juju:master Feb 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment