func TestWipeoutBuildPathIfBuildOptionsChangedNoPreviousBuildOptions(t *testing.T) { context := make(map[string]interface{}) buildPath := SetupBuildPath(t, context) defer os.RemoveAll(buildPath) context[constants.CTX_BUILD_OPTIONS_JSON] = "new" utils.TouchFile(filepath.Join(buildPath, "should_not_be_deleted.txt")) commands := []types.Command{ &builder.SetupHumanLoggerIfMissing{}, &builder.WipeoutBuildPathIfBuildOptionsChanged{}, } for _, command := range commands { err := command.Run(context) NoError(t, err) } _, err := os.Stat(buildPath) NoError(t, err) files, err := gohasissues.ReadDir(buildPath) NoError(t, err) require.Equal(t, 1, len(files)) _, err = os.Stat(filepath.Join(buildPath, "should_not_be_deleted.txt")) NoError(t, err) }
func TestWipeoutBuildPathIfBuildOptionsChangedNoPreviousBuildOptions(t *testing.T) { ctx := &types.Context{} buildPath := SetupBuildPath(t, ctx) defer os.RemoveAll(buildPath) ctx.BuildOptionsJson = "{ \"new\":\"new\" }" utils.TouchFile(filepath.Join(buildPath, "should_not_be_deleted.txt")) commands := []types.Command{ &builder.WipeoutBuildPathIfBuildOptionsChanged{}, } for _, command := range commands { err := command.Run(ctx) NoError(t, err) } _, err := os.Stat(buildPath) NoError(t, err) files, err := gohasissues.ReadDir(buildPath) NoError(t, err) require.Equal(t, 1, len(files)) _, err = os.Stat(filepath.Join(buildPath, "should_not_be_deleted.txt")) NoError(t, err) }