~mattfarina/golang-client/master

« back to all changes in this revision

Viewing changes to misc/util_test.go

  • Committer: Chris Robinson
  • Date: 2014-10-27 21:09:26 UTC
  • Revision ID: git-v1:219cc1c2c1abac86d34faf5b1810478393af74cd
Added Capability to get images and images with details

        new file:   examples/30-image-v1.go
        modified:   examples/config.json.dist
        modified:   examples/setup.go
        modified:   identity/v2/auth.go
        new file:   image/v1/image.go
        new file:   image/v1/image_test.go
        new file:   misc/rfc8601DateTime.go
        new file:   misc/rfc8601DateTime_test.go
        modified:   misc/util.go
        modified:   misc/util_test.go
        modified:   objectstorage/v1/objectstorage.go
        modified:   objectstorage/v1/objectstorage_test.go
        new file:   testUtil/testUtil.go

Partially implements blueprint image-v1

Change-Id: I6277a5c8915f45f4b7585855d836015ffd9e1c12

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
        "bytes"
19
19
        "errors"
20
20
        "git.openstack.org/stackforge/golang-client.git/misc"
 
21
        "git.openstack.org/stackforge/golang-client.git/testUtil"
21
22
        "io/ioutil"
22
23
        "net/http"
23
24
        "net/http/httptest"
25
26
        "testing"
26
27
)
27
28
 
 
29
var token = "2350971-5716-8165"
 
30
 
 
31
func TestDelete(t *testing.T) {
 
32
        var apiServer = testUtil.CreateDeleteTestRequestServer(t, token, "/other")
 
33
        defer apiServer.Close()
 
34
 
 
35
        err := misc.Delete(apiServer.URL+"/other", token, *http.DefaultClient)
 
36
        testUtil.IsNil(t, err)
 
37
}
 
38
 
 
39
func TestPostJsonWithValidResponse(t *testing.T) {
 
40
        var apiServer = testUtil.CreatePostJSONTestRequestServer(t, token, `{"id":"id1","name":"Chris"}`, "", `{"id":"id1","name":"name"}`)
 
41
        defer apiServer.Close()
 
42
        actual := TestStruct{}
 
43
        ti := TestStruct{ID: "id1", Name: "name"}
 
44
 
 
45
        err := misc.PostJSON(apiServer.URL, token, *http.DefaultClient, ti, &actual)
 
46
        testUtil.IsNil(t, err)
 
47
        expected := TestStruct{ID: "id1", Name: "Chris"}
 
48
 
 
49
        testUtil.Equals(t, expected, actual)
 
50
}
 
51
 
28
52
func TestCallAPI(t *testing.T) {
29
53
        tokn := "eaaafd18-0fed-4b3a-81b4-663c99ec1cbb"
30
54
        var apiServer = httptest.NewServer(http.HandlerFunc(
108
132
                t.Error(err)
109
133
        }
110
134
}
 
135
 
 
136
type TestStruct struct {
 
137
        ID   string `json:"id"`
 
138
        Name string `json:"name"`
 
139
}