当前位置: 首页>>代码示例>>Golang>>正文


Golang BitriseDataModel.Validate方法代码示例

本文整理汇总了Golang中github.com/bitrise-io/bitrise/models.BitriseDataModel.Validate方法的典型用法代码示例。如果您正苦于以下问题:Golang BitriseDataModel.Validate方法的具体用法?Golang BitriseDataModel.Validate怎么用?Golang BitriseDataModel.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/bitrise-io/bitrise/models.BitriseDataModel的用法示例。


在下文中一共展示了BitriseDataModel.Validate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Test0Steps3WorkflowsCircularDependency

// Test - Bitrise Validate workflow
// Workflow contains before and after workflow, and no one contains steps, but circular wofklow dependecy exist, which should fail
func Test0Steps3WorkflowsCircularDependency(t *testing.T) {
	require.NoError(t, os.Setenv("BITRISE_BUILD_STATUS", "0"))
	defer func() { require.NoError(t, os.Unsetenv("BITRISE_BUILD_STATUS")) }()

	require.NoError(t, os.Setenv("STEPLIB_BUILD_STATUS", "0"))
	defer func() { require.NoError(t, os.Unsetenv("STEPLIB_BUILD_STATUS")) }()

	beforeWorkflow := models.WorkflowModel{
		BeforeRun: []string{"target"},
	}

	afterWorkflow := models.WorkflowModel{}

	workflow := models.WorkflowModel{
		BeforeRun: []string{"before"},
		AfterRun:  []string{"after"},
	}

	config := models.BitriseDataModel{
		FormatVersion:        "1.0.0",
		DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
		Workflows: map[string]models.WorkflowModel{
			"target": workflow,
			"before": beforeWorkflow,
			"after":  afterWorkflow,
		},
	}

	_, err := config.Validate()
	require.Error(t, err)

	require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
	require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:36,代码来源:run_test.go

示例2: Test0Steps3WorkflowsCircularDependency

// Test - Bitrise Validate workflow
// Workflow contains before and after workflow, and no one contains steps, but circular wofklow dependecy exist, which should fail
func Test0Steps3WorkflowsCircularDependency(t *testing.T) {
	if err := os.Setenv("BITRISE_BUILD_STATUS", "0"); err != nil {
		t.Fatal(err)
	}
	defer func() {
		// env cleanup
		if err := os.Unsetenv("BITRISE_BUILD_STATUS"); err != nil {
			t.Error("Failed to unset environment: ", err)
		}
	}()
	if err := os.Setenv("STEPLIB_BUILD_STATUS", "0"); err != nil {
		t.Fatal(err)
	}
	defer func() {
		// env cleanup
		if err := os.Unsetenv("STEPLIB_BUILD_STATUS"); err != nil {
			t.Error("Failed to unset environment: ", err)
		}
	}()

	beforeWorkflow := models.WorkflowModel{
		BeforeRun: []string{"target"},
	}

	afterWorkflow := models.WorkflowModel{}

	workflow := models.WorkflowModel{
		BeforeRun: []string{"before"},
		AfterRun:  []string{"after"},
	}

	config := models.BitriseDataModel{
		FormatVersion:        "1.0.0",
		DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
		Workflows: map[string]models.WorkflowModel{
			"target": workflow,
			"before": beforeWorkflow,
			"after":  afterWorkflow,
		},
	}

	if err := config.Validate(); err == nil {
		t.Fatal("Circular dependency, should fail")
	}

	if status := os.Getenv("BITRISE_BUILD_STATUS"); status != "0" {
		t.Log("BITRISE_BUILD_STATUS:", status)
		t.Fatal("BUILD_STATUS envs are incorrect")
	}
	if status := os.Getenv("STEPLIB_BUILD_STATUS"); status != "0" {
		t.Log("STEPLIB_BUILD_STATUS:", status)
		t.Fatal("STEPLIB_BUILD_STATUS envs are incorrect")
	}
}
开发者ID:andrewhavens,项目名称:bitrise,代码行数:56,代码来源:run_test.go

示例3: normalizeValidateFillMissingDefaults

func normalizeValidateFillMissingDefaults(bitriseData *models.BitriseDataModel) error {
	if err := bitriseData.Normalize(); err != nil {
		return err
	}
	if err := bitriseData.Validate(); err != nil {
		return err
	}
	if err := bitriseData.FillMissingDefaults(); err != nil {
		return err
	}
	return nil
}
开发者ID:bitrise-io,项目名称:bitrise-yml-converter,代码行数:12,代码来源:util.go

示例4: normalizeValidateFillMissingDefaults

func normalizeValidateFillMissingDefaults(bitriseData *models.BitriseDataModel) ([]string, error) {
	if err := bitriseData.Normalize(); err != nil {
		return []string{}, err
	}
	warnings, err := bitriseData.Validate()
	if err != nil {
		return warnings, err
	}
	if err := bitriseData.FillMissingDefaults(); err != nil {
		return warnings, err
	}
	return warnings, nil
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:13,代码来源:util.go

示例5: Test0Steps3WorkflowsBeforeAfter

// Test - Bitrise activateAndRunWorkflow
// Workflow contains before and after workflow, and no one contains steps
func Test0Steps3WorkflowsBeforeAfter(t *testing.T) {
	require.NoError(t, os.Setenv("BITRISE_BUILD_STATUS", "0"))
	defer func() { require.NoError(t, os.Unsetenv("BITRISE_BUILD_STATUS")) }()

	require.NoError(t, os.Setenv("STEPLIB_BUILD_STATUS", "0"))
	defer func() { require.NoError(t, os.Unsetenv("STEPLIB_BUILD_STATUS")) }()

	beforeWorkflow := models.WorkflowModel{}
	afterWorkflow := models.WorkflowModel{}

	workflow := models.WorkflowModel{
		BeforeRun: []string{"before"},
		AfterRun:  []string{"after"},
	}

	config := models.BitriseDataModel{
		FormatVersion:        "1.0.0",
		DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
		Workflows: map[string]models.WorkflowModel{
			"target": workflow,
			"before": beforeWorkflow,
			"after":  afterWorkflow,
		},
	}

	_, err := config.Validate()
	require.NoError(t, err)

	buildRunResults := models.BuildRunResultsModel{
		StartTime:      time.Now(),
		StepmanUpdates: map[string]int{},
	}

	buildRunResults, err = activateAndRunWorkflow("target", workflow, config, buildRunResults, &[]envmanModels.EnvironmentItemModel{}, "")
	require.NoError(t, err)
	require.Equal(t, 0, len(buildRunResults.SuccessSteps))
	require.Equal(t, 0, len(buildRunResults.FailedSteps))
	require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
	require.Equal(t, 0, len(buildRunResults.SkippedSteps))

	require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
	require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:45,代码来源:run_test.go

示例6: Test0Steps1Workflows

// Test - Bitrise activateAndRunWorkflow
// If workflow contains no steps
func Test0Steps1Workflows(t *testing.T) {
	workflow := models.WorkflowModel{}

	require.NoError(t, os.Setenv("BITRISE_BUILD_STATUS", "0"))
	defer func() { require.NoError(t, os.Unsetenv("BITRISE_BUILD_STATUS")) }()

	require.NoError(t, os.Setenv("STEPLIB_BUILD_STATUS", "0"))
	defer func() { require.NoError(t, os.Unsetenv("STEPLIB_BUILD_STATUS")) }()

	config := models.BitriseDataModel{
		FormatVersion:        "1.0.0",
		DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
		Workflows: map[string]models.WorkflowModel{
			"zero_steps": workflow,
		},
	}

	_, err := config.Validate()
	require.NoError(t, err)

	buildRunResults := models.BuildRunResultsModel{
		StartTime:      time.Now(),
		StepmanUpdates: map[string]int{},
	}

	require.NoError(t, configs.InitPaths())

	buildRunResults, err = runWorkflowWithConfiguration(time.Now(), "zero_steps", config, []envmanModels.EnvironmentItemModel{})
	require.NoError(t, err)
	require.Equal(t, 0, len(buildRunResults.SuccessSteps))
	require.Equal(t, 0, len(buildRunResults.FailedSteps))
	require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
	require.Equal(t, 0, len(buildRunResults.SkippedSteps))

	require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
	require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:39,代码来源:run_test.go

示例7: Test0Steps3WorkflowsBeforeAfter

// Test - Bitrise activateAndRunWorkflow
// Workflow contains before and after workflow, and no one contains steps
func Test0Steps3WorkflowsBeforeAfter(t *testing.T) {
	if err := os.Setenv("BITRISE_BUILD_STATUS", "0"); err != nil {
		t.Fatal(err)
	}
	defer func() {
		// env cleanup
		if err := os.Unsetenv("BITRISE_BUILD_STATUS"); err != nil {
			t.Error("Failed to unset environment: ", err)
		}
	}()
	if err := os.Setenv("STEPLIB_BUILD_STATUS", "0"); err != nil {
		t.Fatal(err)
	}
	defer func() {
		// env cleanup
		if err := os.Unsetenv("STEPLIB_BUILD_STATUS"); err != nil {
			t.Error("Failed to unset environment: ", err)
		}
	}()

	beforeWorkflow := models.WorkflowModel{}
	afterWorkflow := models.WorkflowModel{}

	workflow := models.WorkflowModel{
		BeforeRun: []string{"before"},
		AfterRun:  []string{"after"},
	}

	config := models.BitriseDataModel{
		FormatVersion:        "1.0.0",
		DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
		Workflows: map[string]models.WorkflowModel{
			"target": workflow,
			"before": beforeWorkflow,
			"after":  afterWorkflow,
		},
	}

	if err := config.Validate(); err != nil {
		t.Fatal(err)
	}

	buildRunResults := models.BuildRunResultsModel{
		StartTime:      time.Now(),
		StepmanUpdates: map[string]int{},
	}
	var err error
	buildRunResults, err = activateAndRunWorkflow("target", workflow, config, buildRunResults, &[]envmanModels.EnvironmentItemModel{}, "")
	if err != nil {
		t.Fatal("Failed to activate and run worfklow:", err)
	}
	if len(buildRunResults.SuccessSteps) != 0 {
		t.Fatalf("Success step count (%d), should be (0)", len(buildRunResults.SuccessSteps))
	}
	if len(buildRunResults.FailedSteps) != 0 {
		t.Fatalf("Failed step count (%d), should be (0)", len(buildRunResults.FailedSteps))
	}
	if len(buildRunResults.FailedSkippableSteps) != 0 {
		t.Fatalf("FailedSkippable step count (%d), should be (0)", len(buildRunResults.FailedSkippableSteps))
	}
	if len(buildRunResults.SkippedSteps) != 0 {
		t.Fatalf("Skipped step count (%d), should be (0)", len(buildRunResults.SkippedSteps))
	}

	if status := os.Getenv("BITRISE_BUILD_STATUS"); status != "0" {
		t.Log("BITRISE_BUILD_STATUS:", status)
		t.Fatal("BUILD_STATUS envs are incorrect")
	}
	if status := os.Getenv("STEPLIB_BUILD_STATUS"); status != "0" {
		t.Log("STEPLIB_BUILD_STATUS:", status)
		t.Fatal("STEPLIB_BUILD_STATUS envs are incorrect")
	}
}
开发者ID:andrewhavens,项目名称:bitrise,代码行数:75,代码来源:run_test.go

示例8: Test0Steps1Workflows

// Test - Bitrise activateAndRunWorkflow
// If workflow contains no steps
func Test0Steps1Workflows(t *testing.T) {
	workflow := models.WorkflowModel{}

	if err := os.Setenv("BITRISE_BUILD_STATUS", "0"); err != nil {
		t.Fatal(err)
	}
	defer func() {
		// env cleanup
		if err := os.Unsetenv("BITRISE_BUILD_STATUS"); err != nil {
			t.Error("Failed to unset environment: ", err)
		}
	}()
	if err := os.Setenv("STEPLIB_BUILD_STATUS", "0"); err != nil {
		t.Fatal(err)
	}
	defer func() {
		// env cleanup
		if err := os.Unsetenv("STEPLIB_BUILD_STATUS"); err != nil {
			t.Error("Failed to unset environment: ", err)
		}
	}()

	config := models.BitriseDataModel{
		FormatVersion:        "1.0.0",
		DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
		Workflows: map[string]models.WorkflowModel{
			"zero_steps": workflow,
		},
	}

	if err := config.Validate(); err != nil {
		t.Fatal(err)
	}

	buildRunResults := models.BuildRunResultsModel{
		StartTime:      time.Now(),
		StepmanUpdates: map[string]int{},
	}
	buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "zero_steps", config, []envmanModels.EnvironmentItemModel{})
	t.Log("Err: ", err)
	if len(buildRunResults.SuccessSteps) != 0 {
		t.Fatalf("Success step count (%d), should be (0)", len(buildRunResults.SuccessSteps))
	}
	if len(buildRunResults.FailedSteps) != 0 {
		t.Fatalf("Failed step count (%d), should be (0)", len(buildRunResults.FailedSteps))
	}
	if len(buildRunResults.FailedSkippableSteps) != 0 {
		t.Fatalf("FailedSkippable step count (%d), should be (0)", len(buildRunResults.FailedSkippableSteps))
	}
	if len(buildRunResults.SkippedSteps) != 0 {
		t.Fatalf("Skipped step count (%d), should be (0)", len(buildRunResults.SkippedSteps))
	}

	if status := os.Getenv("BITRISE_BUILD_STATUS"); status != "0" {
		t.Log("BITRISE_BUILD_STATUS:", status)
		t.Fatal("BUILD_STATUS envs are incorrect")
	}
	if status := os.Getenv("STEPLIB_BUILD_STATUS"); status != "0" {
		t.Log("STEPLIB_BUILD_STATUS:", status)
		t.Fatal("STEPLIB_BUILD_STATUS envs are incorrect")
	}
}
开发者ID:andrewhavens,项目名称:bitrise,代码行数:64,代码来源:run_test.go


注:本文中的github.com/bitrise-io/bitrise/models.BitriseDataModel.Validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。