Beispiel #1
0
func TestBuilderPrepare_Warnings(t *testing.T) {
	b := new(packer.MockBuilder)
	client, server := testClientServer(t)
	defer client.Close()
	defer server.Close()
	server.RegisterBuilder(b)
	bClient := client.Builder()

	expected := []string{"foo"}
	b.PrepareWarnings = expected

	// Test Prepare
	warnings, err := bClient.Prepare(nil)
	if err != nil {
		t.Fatalf("bad: %s", err)
	}
	if !reflect.DeepEqual(warnings, expected) {
		t.Fatalf("bad: %#v", warnings)
	}
}
Beispiel #2
0
func TestBuilderRun_nilResult(t *testing.T) {
	b := new(packer.MockBuilder)
	b.RunNilResult = true

	client, server := testClientServer(t)
	defer client.Close()
	defer server.Close()
	server.RegisterBuilder(b)
	bClient := client.Builder()

	cache := new(testCache)
	hook := &packer.MockHook{}
	ui := &testUi{}
	artifact, err := bClient.Run(ui, hook, cache)
	if artifact != nil {
		t.Fatalf("bad: %#v", artifact)
	}
	if err != nil {
		t.Fatalf("bad: %#v", err)
	}
}