Ejemplo n.º 1
0
func TestListRecords(t *testing.T) {
	commands.ResetVars()

	args := strings.Split("list", " ")
	shamanTool.SetArgs(args)

	out, err := capture(shamanTool.Execute)
	if err != nil {
		t.Errorf("Failed to execute - %v", err.Error())
	}

	if string(out) != "[\"nanobox.io\"]\n" {
		t.Errorf("Unexpected output: %+q", string(out))
	}

	args = strings.Split("list -f", " ")
	shamanTool.SetArgs(args)

	out, err = capture(shamanTool.Execute)
	if err != nil {
		t.Errorf("Failed to execute - %v", err.Error())
	}

	if string(out) != "[{\"domain\":\"nanobox.io.\",\"records\":[{\"ttl\":60,\"class\":\"IN\",\"type\":\"A\",\"address\":\"127.0.0.1\"}]}]\n" {
		t.Errorf("Unexpected output: %+q", string(out))
	}
}
Ejemplo n.º 2
0
func TestResetRecords(t *testing.T) {
	commands.ResetVars()

	args := strings.Split("reset -j [{\"domain\":\"nanopack.io\"}]", " ")
	shamanTool.SetArgs(args)

	out, err := capture(shamanTool.Execute)
	if err != nil {
		t.Errorf("Failed to execute - %v", err.Error())
	}

	if string(out) != "[{\"domain\":\"nanopack.io.\",\"records\":null}]\n" {
		t.Errorf("Unexpected output: %+q", string(out))
	}

	args = strings.Split("list", " ")
	shamanTool.SetArgs(args)

	out, err = capture(shamanTool.Execute)
	if err != nil {
		t.Errorf("Failed to execute - %v", err.Error())
	}

	if string(out) != "[\"nanopack.io\"]\n" {
		t.Errorf("Unexpected output: %+q", string(out))
	}
}
Ejemplo n.º 3
0
func TestDeleteRecord(t *testing.T) {
	commands.ResetVars()

	args := strings.Split("delete -d nanopack.io", " ")
	shamanTool.SetArgs(args)

	out, err := capture(shamanTool.Execute)
	if err != nil {
		t.Errorf("Failed to execute - %v", err.Error())
	}

	if string(out) != "{\"msg\":\"success\"}\n" {
		t.Errorf("Unexpected output: %+q", string(out))
	}
}
Ejemplo n.º 4
0
func TestGetRecord(t *testing.T) {
	commands.ResetVars()

	args := strings.Split("get -d nanopack.io", " ")
	shamanTool.SetArgs(args)

	out, err := capture(shamanTool.Execute)
	if err != nil {
		t.Errorf("Failed to execute - %v", err.Error())
	}

	if string(out) != "{\"domain\":\"nanopack.io.\",\"records\":[{\"ttl\":60,\"class\":\"IN\",\"type\":\"A\",\"address\":\"127.0.0.5\"}]}\n" {
		t.Errorf("Unexpected output: %+q", string(out))
	}
}