From 982044a8bd8089f7caf314377a8f0d0c698d31b8 Mon Sep 17 00:00:00 2001 From: Ivan Kamkin <234-Ivan.Kamkin@users.noreply.git.saltov.dynabic.com> Date: Wed, 22 Jan 2025 16:33:26 +0500 Subject: [PATCH] Fixed tests and snippets --- .github/workflows/go.yml | 6 ++- snippets/generate/appearance/generate_body.go | 2 +- snippets/generate/appearance/generate_get.go | 2 +- .../generate/appearance/generate_multipart.go | 2 +- snippets/generate/save/generate_body.go | 2 +- snippets/generate/save/generate_get.go | 2 +- snippets/generate/save/generate_multipart.go | 2 +- .../generate/set_colorscheme/generate_body.go | 2 +- .../generate/set_colorscheme/generate_get.go | 2 +- .../set_colorscheme/generate_multipart.go | 2 +- snippets/generate/set_size/generate_body.go | 2 +- snippets/generate/set_size/generate_get.go | 2 +- .../generate/set_size/generate_multipart.go | 2 +- snippets/generate/set_text/generate_body.go | 2 +- snippets/generate/set_text/generate_get.go | 2 +- .../generate/set_text/generate_multipart.go | 2 +- snippets/manual_fetch_token.go | 6 +++ .../read/set_image_kind/recognize_body.go | 2 +- snippets/read/set_image_kind/recognize_get.go | 2 +- .../set_image_kind/recognize_multipart.go | 2 +- snippets/read/set_quality/recognize_body.go | 2 +- snippets/read/set_quality/recognize_get.go | 2 +- .../read/set_quality/recognize_multipart.go | 2 +- snippets/read/set_source/recognize_body.go | 2 +- .../read/set_source/recognize_multipart.go | 2 +- snippets/read/set_source/scan_body.go | 2 +- snippets/read/set_source/scan_get.go | 2 +- snippets/read/set_source/scan_multipart.go | 2 +- .../read/set_target_types/recognize_body.go | 2 +- .../read/set_target_types/recognize_get.go | 2 +- .../set_target_types/recognize_multipart.go | 2 +- test/configuration_test.go | 2 +- test/scan_test.go | 40 ------------------- 33 files changed, 40 insertions(+), 72 deletions(-) delete mode 100644 test/scan_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 27d28ff..489cf0a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,6 +29,8 @@ jobs: run: make init - name: Build and Test - run: make ci + run: | + chmod +x scripts/* + make ci env: - TEST_JWT_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }} + TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }} diff --git a/snippets/generate/appearance/generate_body.go b/snippets/generate/appearance/generate_body.go index 42901d7..46c8c92 100644 --- a/snippets/generate/appearance/generate_body.go +++ b/snippets/generate/appearance/generate_body.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/appearance/generate_get.go b/snippets/generate/appearance/generate_get.go index 65e29a6..4e8c77c 100644 --- a/snippets/generate/appearance/generate_get.go +++ b/snippets/generate/appearance/generate_get.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/appearance/generate_multipart.go b/snippets/generate/appearance/generate_multipart.go index ee42afc..6315e1a 100644 --- a/snippets/generate/appearance/generate_multipart.go +++ b/snippets/generate/appearance/generate_multipart.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/save/generate_body.go b/snippets/generate/save/generate_body.go index e0be549..3880e9f 100644 --- a/snippets/generate/save/generate_body.go +++ b/snippets/generate/save/generate_body.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/save/generate_get.go b/snippets/generate/save/generate_get.go index c5b6820..c9ce7e7 100644 --- a/snippets/generate/save/generate_get.go +++ b/snippets/generate/save/generate_get.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/save/generate_multipart.go b/snippets/generate/save/generate_multipart.go index 31b368d..eed08be 100644 --- a/snippets/generate/save/generate_multipart.go +++ b/snippets/generate/save/generate_multipart.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_colorscheme/generate_body.go b/snippets/generate/set_colorscheme/generate_body.go index e0be549..3880e9f 100644 --- a/snippets/generate/set_colorscheme/generate_body.go +++ b/snippets/generate/set_colorscheme/generate_body.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_colorscheme/generate_get.go b/snippets/generate/set_colorscheme/generate_get.go index b950f7b..58feb83 100644 --- a/snippets/generate/set_colorscheme/generate_get.go +++ b/snippets/generate/set_colorscheme/generate_get.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_colorscheme/generate_multipart.go b/snippets/generate/set_colorscheme/generate_multipart.go index 167a4c5..352f21a 100644 --- a/snippets/generate/set_colorscheme/generate_multipart.go +++ b/snippets/generate/set_colorscheme/generate_multipart.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_size/generate_body.go b/snippets/generate/set_size/generate_body.go index 0c3c568..485d061 100644 --- a/snippets/generate/set_size/generate_body.go +++ b/snippets/generate/set_size/generate_body.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_size/generate_get.go b/snippets/generate/set_size/generate_get.go index 6fa2414..c32250a 100644 --- a/snippets/generate/set_size/generate_get.go +++ b/snippets/generate/set_size/generate_get.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_size/generate_multipart.go b/snippets/generate/set_size/generate_multipart.go index ad46137..b4dae88 100644 --- a/snippets/generate/set_size/generate_multipart.go +++ b/snippets/generate/set_size/generate_multipart.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_text/generate_body.go b/snippets/generate/set_text/generate_body.go index 1144782..1826555 100644 --- a/snippets/generate/set_text/generate_body.go +++ b/snippets/generate/set_text/generate_body.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_text/generate_get.go b/snippets/generate/set_text/generate_get.go index 162df78..09a53dc 100644 --- a/snippets/generate/set_text/generate_get.go +++ b/snippets/generate/set_text/generate_get.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/generate/set_text/generate_multipart.go b/snippets/generate/set_text/generate_multipart.go index 096060b..2a281c1 100644 --- a/snippets/generate/set_text/generate_multipart.go +++ b/snippets/generate/set_text/generate_multipart.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/manual_fetch_token.go b/snippets/manual_fetch_token.go index 08c2256..418ece1 100644 --- a/snippets/manual_fetch_token.go +++ b/snippets/manual_fetch_token.go @@ -6,12 +6,18 @@ import ( "fmt" "log" "net/http" + "strings" ) func main() { clientID := "Client Id from https://dashboard.aspose.cloud/applications" clientSecret := "Client Secret from https://dashboard.aspose.cloud/applications" + if strings.HasPrefix(clientID, "Client Id"){ + fmt.Println("clientID not configured. Skip this snippet test") + return + } + baseURL := "https://id.aspose.cloud/" endpoint := "connect/token" diff --git a/snippets/read/set_image_kind/recognize_body.go b/snippets/read/set_image_kind/recognize_body.go index c1126ed..df8a372 100644 --- a/snippets/read/set_image_kind/recognize_body.go +++ b/snippets/read/set_image_kind/recognize_body.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_image_kind/recognize_get.go b/snippets/read/set_image_kind/recognize_get.go index bee487a..8317138 100644 --- a/snippets/read/set_image_kind/recognize_get.go +++ b/snippets/read/set_image_kind/recognize_get.go @@ -10,7 +10,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_image_kind/recognize_multipart.go b/snippets/read/set_image_kind/recognize_multipart.go index 7a2dd64..be1789e 100644 --- a/snippets/read/set_image_kind/recognize_multipart.go +++ b/snippets/read/set_image_kind/recognize_multipart.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_quality/recognize_body.go b/snippets/read/set_quality/recognize_body.go index 17955ae..7fe06a7 100644 --- a/snippets/read/set_quality/recognize_body.go +++ b/snippets/read/set_quality/recognize_body.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_quality/recognize_get.go b/snippets/read/set_quality/recognize_get.go index c0cf59b..a0cabdf 100644 --- a/snippets/read/set_quality/recognize_get.go +++ b/snippets/read/set_quality/recognize_get.go @@ -10,7 +10,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_quality/recognize_multipart.go b/snippets/read/set_quality/recognize_multipart.go index 6a0ae3b..06122c1 100644 --- a/snippets/read/set_quality/recognize_multipart.go +++ b/snippets/read/set_quality/recognize_multipart.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_source/recognize_body.go b/snippets/read/set_source/recognize_body.go index 47e42ef..db7302e 100644 --- a/snippets/read/set_source/recognize_body.go +++ b/snippets/read/set_source/recognize_body.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_source/recognize_multipart.go b/snippets/read/set_source/recognize_multipart.go index b63a5dd..36521e1 100644 --- a/snippets/read/set_source/recognize_multipart.go +++ b/snippets/read/set_source/recognize_multipart.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_source/scan_body.go b/snippets/read/set_source/scan_body.go index 7bacff7..a88832a 100644 --- a/snippets/read/set_source/scan_body.go +++ b/snippets/read/set_source/scan_body.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_source/scan_get.go b/snippets/read/set_source/scan_get.go index d7ddcc2..69f4514 100644 --- a/snippets/read/set_source/scan_get.go +++ b/snippets/read/set_source/scan_get.go @@ -10,7 +10,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_source/scan_multipart.go b/snippets/read/set_source/scan_multipart.go index 62c7d2d..74ba2ca 100644 --- a/snippets/read/set_source/scan_multipart.go +++ b/snippets/read/set_source/scan_multipart.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_target_types/recognize_body.go b/snippets/read/set_target_types/recognize_body.go index 6ce6add..76b474b 100644 --- a/snippets/read/set_target_types/recognize_body.go +++ b/snippets/read/set_target_types/recognize_body.go @@ -13,7 +13,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_target_types/recognize_get.go b/snippets/read/set_target_types/recognize_get.go index 440c1c3..a78d31b 100644 --- a/snippets/read/set_target_types/recognize_get.go +++ b/snippets/read/set_target_types/recognize_get.go @@ -10,7 +10,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/snippets/read/set_target_types/recognize_multipart.go b/snippets/read/set_target_types/recognize_multipart.go index 44f772e..3a665cd 100644 --- a/snippets/read/set_target_types/recognize_multipart.go +++ b/snippets/read/set_target_types/recognize_multipart.go @@ -11,7 +11,7 @@ import ( ) func makeConfiguration() (*barcode.APIClient, context.Context, error) { - jwtToken := os.Getenv("TEST_CONFIGURATION_JWT_TOKEN") + jwtToken := os.Getenv("TEST_CONFIGURATION_ACCESS_TOKEN") if jwtToken != "" { config := barcode.NewConfiguration() config.AddDefaultHeader("Authorization", "Bearer "+jwtToken) diff --git a/test/configuration_test.go b/test/configuration_test.go index 829589b..ca8c873 100644 --- a/test/configuration_test.go +++ b/test/configuration_test.go @@ -16,7 +16,7 @@ func TestNewConfigurationBasePath(t *testing.T) { } func TestNewConfigurationUserAgentWithRegex(t *testing.T) { - wantPattern := `^Aspose-Barcode-SDK/1\.\d{4}\.\d+/go$` + wantPattern := `^Aspose-Barcode-SDK/4\.\d{4}\.\d+/go$` if got := api.NewConfiguration().UserAgent; !regexp.MustCompile(wantPattern).MatchString(got) { t.Errorf("NewConfiguration().UserAgent = %s; want pattern %s", got, wantPattern) } diff --git a/test/scan_test.go b/test/scan_test.go deleted file mode 100644 index b102f1c..0000000 --- a/test/scan_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package test - -import ( - "os" - "testing" - - "github.com/antihax/optional" - "github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/barcode" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestScanCode39(t *testing.T) { - authCtx, err := NewAuthContextForTests() - require.Nil(t, err) - - client, err := NewClientForTests() - require.Nil(t, err) - - fileName := "../testdata/Code39.jpg" - - imageFile, err := os.Open(fileName) - require.Nil(t, err) - - optionals := barcode.BarcodeApiScanBarcodeOpts{ - DecodeTypes: optional.NewInterface([]barcode.DecodeBarcodeType{ - barcode.DecodeBarcodeTypeCode39Extended, - }), - ChecksumValidation: optional.NewString(string(barcode.ChecksumValidationOff)), - } - recognized, _, err := client.BarcodeApi.ScanBarcode(authCtx, imageFile, &optionals) - require.Nil(t, err) - require.Equal(t, 1, len(recognized.Barcodes)) - - assert.Equal(t, string(barcode.DecodeBarcodeTypeCode39Extended), recognized.Barcodes[0].Type) - assert.Equal(t, "8M93", recognized.Barcodes[0].BarcodeValue) - require.Greater(t, len(recognized.Barcodes[0].Region), 0) - assert.Greater(t, recognized.Barcodes[0].Region[0].X, int32(0)) - assert.Greater(t, recognized.Barcodes[0].Region[0].Y, int32(0)) -}