-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
112 lines (87 loc) · 2.47 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Author: Vignesh Kumar
* Copyright: vigneshuvi
* Date: 01/07/2019
* This file contains the Main.
*/
package main
import "testing"
import services "./services"
const (
dev = "DEV"
qa = "QA"
prod = "PROD"
)
func TestHTTPServerStart(t *testing.T) {
// test stuff here...
t.Log("MAIN: Test HTTP Server Start")
start(true)
profile := services.GetProfileService()
if profile.SeverStatus != true {
t.Error("MAIN ERROR: HTTP server is not yet started")
}
if profile.ServiceCount != 7 {
t.Errorf("MAIN ERROR: Register service is expected %d", profile.ServiceCount)
}
}
func TestEnvArguments(t *testing.T) {
t.Log("MAIN: Testing the environment aruguments")
if len(defaultEnv) == 0 {
t.Error("MAIN ERROR: Default Environment Name: DEV")
}
envName := getArgument(dev)
if envName != dev {
t.Errorf("MAIN ERROR: Environment Name: %s", envName)
}
envName = getArgument(qa)
if envName != qa {
t.Errorf("MAIN ERROR: Environment Name: %s", envName)
}
envName = getArgument(prod)
if envName != prod {
t.Errorf("MAIN ERROR: Environment Name: %s", envName)
}
}
func TestEnvironment(t *testing.T) {
envConfig := getEnvironmentConfig(dev)
t.Log("MAIN: Port number is expected : 3000")
if envConfig.HTTP.Enable {
t.Log("MAIN: HTTP Config is enabled.")
if envConfig.HTTP.Port != 3000 {
t.Errorf("MAIN ERROR: Configuration of port: %d", envConfig.HTTP.Port)
}
}
if envConfig.HTTPS.Enable {
t.Log("MAIN: HTTPs Config is enabled.")
if envConfig.HTTPS.Port != 3043 {
t.Errorf("MAIN ERROR: Configuration of port: %d", envConfig.HTTP.Port)
}
if len(envConfig.HTTPS.Option.Key) == 0 {
t.Error("MAIN ERROR: HTTPS is key is empty")
}
if len(envConfig.HTTPS.Option.Cert) == 0 {
t.Error("MAIN ERROR: HTTPS is Cert is empty")
}
}
if envConfig.HTTP.Port != 3000 {
t.Errorf("MAIN ERROR: Configuration of port: %d", envConfig.HTTP.Port)
}
t.Log("MAIN: API Version is expected : v1")
if envConfig.Version != "v1" {
t.Errorf("MAIN ERROR: API Version is %s", envConfig.Version)
}
}
func TestHTTPServerStatus(t *testing.T) {
// test stuff here...
t.Log("MAIN: Test HTTP Server Status")
envConfig := getEnvironmentConfig(dev)
startHTTPServer(true, envConfig.HTTP.Port)
profile := services.GetProfileService()
if profile.SeverStatus != true {
t.Error("MAIN ERROR: HTTP server is not yet started")
}
//startHTTPServer(false, 3000)
if profile.SeverStatus != true {
t.Error("MAIN ERROR: HTTP server is not yet started")
}
}