From d4cfdc4e584565e55d810adb1599cef062571d99 Mon Sep 17 00:00:00 2001 From: Christopher Zell Date: Fri, 18 Nov 2022 14:34:34 +0100 Subject: [PATCH] try extra interface --- go-chaos/cmd/deploy.go | 2 +- go-chaos/internal/zeebe.go | 16 +++++++++++----- go-chaos/internal/zeebe_test.go | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go-chaos/cmd/deploy.go b/go-chaos/cmd/deploy.go index 69e61fc71..8bb59cd74 100644 --- a/go-chaos/cmd/deploy.go +++ b/go-chaos/cmd/deploy.go @@ -64,7 +64,7 @@ Defaults to the later, which is useful for experimenting with deployment distrib if len(processModelPath) == 0 { // deploy multi version - err := internal.DeployDifferentVersions(zbClient, int32(multipleVersions)) + err := internal.DeployDifferentVersions(zbClient.NewDeployResourceCommand(), int32(multipleVersions)) if err != nil { panic(err.Error()) } diff --git a/go-chaos/internal/zeebe.go b/go-chaos/internal/zeebe.go index ac0ba799d..2cc31559e 100644 --- a/go-chaos/internal/zeebe.go +++ b/go-chaos/internal/zeebe.go @@ -190,16 +190,22 @@ func readModels(bpmnFileName string, dmnFileName string) (*models, error) { return &models{bpmnBytes: bpmnBytes, dmnBytes: dmnBytes, bpmnFileName: bpmnFileName, dmnFileName: dmnFileName}, nil } -func deployModels(client zbc.Client, models *models) error { +func deployModels(deployer Deployer, models *models) error { _, err := - client.NewDeployResourceCommand().AddResource(models.bpmnBytes, models.bpmnFileName).AddResource(models.dmnBytes, models.dmnFileName).Send(context.TODO()) + deployer.AddResource(models.bpmnBytes, models.bpmnFileName).AddResource(models.dmnBytes, models.dmnFileName).Send(context.TODO()) if err != nil { return err } return nil } -func DeployDifferentVersions(client zbc.Client, versions int32) error { +type Deployer interface { + AddResource(definition []byte, name string) *Deployer + Send(ctx context.Context) (*pb.DeployResourceResponse, error) +} + + +func DeployDifferentVersions(deployer Deployer, versions int32) error { firstModel, err := readModels("bpmn/multi-version/multiVersionModel.bpmn", "bpmn/multi-version/fancyDecision.dmn") if err != nil { return err @@ -216,12 +222,12 @@ func DeployDifferentVersions(client zbc.Client, versions int32) error { count := int32(0) for count < versions { - err := deployModels(client, firstModel) + err := deployModels(deployer, firstModel) if err != nil { return err } - err = deployModels(client, secondModel) + err = deployModels(deployer, secondModel) if err != nil { return err } diff --git a/go-chaos/internal/zeebe_test.go b/go-chaos/internal/zeebe_test.go index b6e8bf036..0f225f3d6 100644 --- a/go-chaos/internal/zeebe_test.go +++ b/go-chaos/internal/zeebe_test.go @@ -330,6 +330,7 @@ func Test_ShouldReadGivenFile(t *testing.T) { } + func Test_ShouldDeployDefaultCountOfModels(t *testing.T) { // given client := CreateFakeZeebeClient()