-
Notifications
You must be signed in to change notification settings - Fork 12
/
main_test.go
49 lines (44 loc) · 983 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"testing"
"fmt"
//"net/http"
//"strings"
//"net/http/httptest"
)
var testCases = []struct {
in string
out string
} {
{"", "a"},
{"aa", "ab"},
{"a9", "ba"},
{"99", "aaa"},
}
func TestCodeGeneration(t *testing.T) {
for _, testCase := range testCases {
expected := testCase.out
response, _ := GenerateNextCode(testCase.in)
if response != expected {
fmt.Println("Expected :"+expected+ " Received :"+response)
t.Error("Test failed")
}
}
}
//func TestCreateShortUrl(t *testing.T) {
// req, _ := http.NewRequest(
// "POST",
// "http://localhost:8080/create/",
// strings.NewReader("url=http://coditas.com"),
// )
//
// recorder := httptest.NewRecorder()
// Create(recorder, req, nil)
// if recorder.Code != http.StatusOK {
// t.Errorf("Expected status 200 Received %d", recorder.Code)
// }
//
// if !strings.Contains(recorder.Body.String(), "SUCCESS") {
// t.Error("Unexpected body in response %q", recorder.Body.String())
// }
//}