forked from nofarb/goHelloWorldServer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhello_server_test.go
41 lines (30 loc) · 898 Bytes
/
hello_server_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
package main
import (
"time"
"testing"
)
func TestGreetingSpecificJohn(t *testing.T) {
time.Sleep(8 * time.Second)
greeting := CreateGreeting("John")
if greeting != "Hello, John\n" {
t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, John\n")
}
}
func TestGreetingSpecificDemo(t *testing.T) {
greeting := CreateGreeting("Demo")
if greeting != "Hello, Demo\n" {
t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, Demo\n")
}
}
/* func TestShowFailure(t *testing.T) {
greeting := CreateGreeting("Demo1")
if greeting != "Hello, Demo\n" {
t.Errorf("Intentional failure. got: %s, want: %s.", greeting, "Hello, Demo\n")
}
} */
func TestGreetingDefault(t *testing.T) {
greeting := CreateGreeting("")
if greeting != "Hello, Guest\n" {
t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, Guest\n")
}
}