Skip to content

Commit 1f39a4d

Browse files
author
Guo Huang
committed
issue #1948, added testing code to test go api
1 parent 75ed978 commit 1f39a4d

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
6+
sw "./swagger"
7+
)
8+
9+
func TestAddPet(t *testing.T) {
10+
t.Log("Testing TestAddPet...")
11+
s := sw.NewPetApi()
12+
newPet := (sw.Pet{Id: 12830, Name: "gopher",
13+
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"})
14+
15+
err := s.AddPet(newPet)
16+
17+
if err != nil {
18+
t.Errorf("Error while adding pet")
19+
t.Log(err)
20+
}
21+
}
22+
23+
func TestGetPetById(t *testing.T) {
24+
t.Log("Testing TestGetPetById...")
25+
26+
s := sw.NewPetApi()
27+
resp, err := s.GetPetById(12830)
28+
if err != nil {
29+
t.Errorf("Error while getting pet by id")
30+
t.Log(err)
31+
} else {
32+
t.Log(resp)
33+
}
34+
}
35+
36+
func TestUpdatePetWithForm(t *testing.T) {
37+
t.Log("Testing UpdatePetWithForm...")
38+
39+
s := sw.NewPetApi()
40+
41+
err := s.UpdatePetWithForm("12830", "golang", "available")
42+
43+
if err != nil {
44+
t.Errorf("Error while updating pet by id")
45+
t.Log(err)
46+
}
47+
}

0 commit comments

Comments
 (0)