From 88ff003e77069b6e173b15cda321b7281266e1ca Mon Sep 17 00:00:00 2001 From: hermeswaldemarin Date: Tue, 5 Dec 2023 08:47:46 +0000 Subject: [PATCH] Adding Pipeline to Test GO SDK --- .github/workflows/main.yml | 14 +++++++++++ go.mod | 1 - sdk/DefaultContextDataDeserializer_test.go | 29 ++++++++++++++++++++-- sdk/jsonmodels/CustomFieldValue.go | 7 ++++++ test.sh | 3 +++ 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 sdk/jsonmodels/CustomFieldValue.go diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fd2e9d2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,14 @@ +name: Go SDK +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Go + uses: actions/setup-go@v4 + + - name: Run Tests + run: + ./test.sh \ No newline at end of file diff --git a/go.mod b/go.mod index 5719691..64942e6 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,4 @@ go 1.15 require ( github.com/go-resty/resty/v2 v2.7.0 - github.com/procyon-projects/chrono v1.1.2 ) diff --git a/sdk/DefaultContextDataDeserializer_test.go b/sdk/DefaultContextDataDeserializer_test.go index 68e6cea..43429fc 100644 --- a/sdk/DefaultContextDataDeserializer_test.go +++ b/sdk/DefaultContextDataDeserializer_test.go @@ -30,6 +30,18 @@ func TestDeserialize(t *testing.T) { }}, AudienceStrict: false, Audience: "", + CustomFieldValues: []jsonmodels.CustomFieldValue{ + { + Name: "country", + Value: "US,PT,ES,DE,FR", + Type: "string", + }, + { + Name: "overrides", + Value: "{\"123\":1,\"456\":0}", + Type: "json", + }, + }, } var experiment_2 = jsonmodels.Experiment{ @@ -59,6 +71,18 @@ func TestDeserialize(t *testing.T) { }}, AudienceStrict: false, Audience: "", + CustomFieldValues: []jsonmodels.CustomFieldValue{ + { + Name: "country", + Value: "US,PT,ES,DE,FR", + Type: "string", + }, + { + Name: "languages", + Value: "en-US,en-GB,pt-PT,pt-BR,es-ES,es-MX", + Type: "string", + }, + }, } var experiment_3 = jsonmodels.Experiment{ @@ -86,8 +110,9 @@ func TestDeserialize(t *testing.T) { Name: "C", Config: "{\"card.width\":\"75%\"}", }}, - AudienceStrict: false, - Audience: "{}", + AudienceStrict: false, + Audience: "{}", + CustomFieldValues: nil, } var experiment_4 = jsonmodels.Experiment{ diff --git a/sdk/jsonmodels/CustomFieldValue.go b/sdk/jsonmodels/CustomFieldValue.go new file mode 100644 index 0000000..0dc55e6 --- /dev/null +++ b/sdk/jsonmodels/CustomFieldValue.go @@ -0,0 +1,7 @@ +package jsonmodels + +type CustomFieldValue struct { + Name string `json:"name"` + Type string `json:"type"` + Value string `json:"value"` +} diff --git a/test.sh b/test.sh index e1fb955..b0d6000 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,8 @@ #!/bin/bash +echo "run golang get" +go get github.com/go-resty/resty/v2@v2.7.0 + echo "run golang fmt" go fmt ./...