Skip to content

Commit

Permalink
fix unit test compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
ochinchina committed Mar 2, 2020
1 parent 608fedb commit 388a2f0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestGetBytesFromConfig(t *testing.T) {
func TestGetUnitHttpServer(t *testing.T) {
config, _ := parse([]byte("[program:test]\nA=1024\nB=2KB\nC=3MB\nD=4GB\nE=test\n[unix_http_server]\n"))

entry, ok := config.GetUnixHttpServer()
entry, ok := config.GetUnixHTTPServer()

if !ok || entry == nil {
t.Error("Fail to get the unix_http_server")
Expand Down
22 changes: 11 additions & 11 deletions config/process_sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
)

//
// check if program1 is before the program2 in the ConfigEntry
// check if program1 is before the program2 in the Entry
//
func isProgramBefore(entries []*ConfigEntry, program1 string, program2 string) bool {
func isProgramBefore(entries []*Entry, program1 string, program2 string) bool {
order := 0
program1Order := -1
progam2Order := -1
Expand All @@ -24,53 +24,53 @@ func isProgramBefore(entries []*ConfigEntry, program1 string, program2 string) b
}
}

fmt.Printf("program1Order=%d, progam2Order=%d\n", program1Order, progam2Order)
fmt.Printf("%s Order=%d, %s Order=%d\n", program1, program1Order, program2, progam2Order)

return program1Order >= 0 && program1Order < progam2Order
}
func TestSortProgram(t *testing.T) {
entries := make([]*ConfigEntry, 0)
entry := NewConfigEntry(".")
entries := make([]*Entry, 0)
entry := NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-1"
entry.keyValues["depends_on"] = "prog-3"

entries = append(entries, entry)

entry = NewConfigEntry(".")
entry = NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-2"
entry.keyValues["depends_on"] = "prog-1"

entries = append(entries, entry)

entry = NewConfigEntry(".")
entry = NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-3"
entry.keyValues["depends_on"] = "prog-4,prog-5"

entries = append(entries, entry)

entry = NewConfigEntry(".")
entry = NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-5"

entries = append(entries, entry)

entry = NewConfigEntry(".")
entry = NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-4"

entries = append(entries, entry)

entry = NewConfigEntry(".")
entry = NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-6"
entry.keyValues["priority"] = "100"

entries = append(entries, entry)

entry = NewConfigEntry(".")
entry = NewEntry(".")
entry.Group = "group:group-1"
entry.Name = "program:prog-7"
entry.keyValues["priority"] = "99"
Expand Down
8 changes: 4 additions & 4 deletions content_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestTcpCheckOk(t *testing.T) {
}
}
}()
checker := NewTcpChecker("127.0.0.1", 8999, []string{"Hello", "world"}, 10)
checker := NewTCPChecker("127.0.0.1", 8999, []string{"Hello", "world"}, 10)
if !checker.Check() {
t.Fail()
}
Expand All @@ -64,7 +64,7 @@ func TestTcpCheckFail(t *testing.T) {
listener.Close()
}
}()
checker := NewTcpChecker("127.0.0.1", 8989, []string{"Hello", "world"}, 2)
checker := NewTCPChecker("127.0.0.1", 8989, []string{"Hello", "world"}, 2)
if checker.Check() {
t.Fail()
}
Expand All @@ -83,7 +83,7 @@ func TestHttpCheckOk(t *testing.T) {

}
}()
checker := NewHttpChecker("http://127.0.0.1:8999", 2)
checker := NewHTTPChecker("http://127.0.0.1:8999", 2)
if !checker.Check() {
t.Fail()
}
Expand All @@ -101,7 +101,7 @@ func TestHttpCheckFail(t *testing.T) {

}
}()
checker := NewHttpChecker("http://127.0.0.1:8999", 2)
checker := NewHTTPChecker("http://127.0.0.1:8999", 2)
if checker.Check() {
t.Fail()
}
Expand Down
2 changes: 1 addition & 1 deletion events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ func CreateProcessUnknownEvent(process string,

// GetBody get the body of process state event
func (pse *ProcessStateEvent) GetBody() string {
body := fmt.Sprintf("processname:%s groupname:%s fromState:%s", pse.processName, pse.groupName, pse.fromState)
body := fmt.Sprintf("processname:%s groupname:%s from_state:%s", pse.processName, pse.groupName, pse.fromState)
if pse.tries >= 0 {
body = fmt.Sprintf("%s tries:%d", body, pse.tries)
}
Expand Down
1 change: 1 addition & 0 deletions events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func TestProcessStartingEvent(t *testing.T) {
if event.GetType() != "PROCESS_STATE_STARTING" {
t.Error("Fail to creating the process starting event")
}
fmt.Printf( "%s\n", event.GetBody() )
if event.GetBody() != "processname:proc-1 groupname:group-1 from_state:STOPPED tries:0" {
t.Error("Fail to encode the process starting event")
}
Expand Down
4 changes: 2 additions & 2 deletions process/process_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"
)

var procs *ProcessManager = NewProcessManager()
var procs *Manager = NewManager()

func TestProcessMgrAdd(t *testing.T) {
entry := &config.ConfigEntry{ConfigDir: ".", Group: "test", Name: "program:test1"}
entry := &config.Entry{ConfigDir: ".", Group: "test", Name: "program:test1"}
procs.Clear()
procs.Add("test1", NewProcess("supervisord", entry))

Expand Down

0 comments on commit 388a2f0

Please sign in to comment.