Code Monkey home page Code Monkey logo

Comments (6)

mvantellingen avatar mvantellingen commented on July 23, 2024

Hi @zackpollard, is this with make mockacc or with make testacc ?

from terraform-provider-commercetools.

zackpollard avatar zackpollard commented on July 23, 2024

This is running with make testacc. Having a space in a key in commercetools is not valid, but i'm guessing it is in the mock server? Unsure what's up with the first error though, would need to investigate more.

from terraform-provider-commercetools.

 avatar commented on July 23, 2024

Not sure if I should create a new issue, but Discount Code resource acceptance tests are also failing, I tried looking into it thinking that there might be some issues in the terraform hlc but couldn't notice anything obvious:

Error:

=== RUN   TestAccDiscountCodeCreate_basic
    TestAccDiscountCodeCreate_basic: testing.go:654: Step 0 error: errors during apply:
        
        Error: Request body does not contain valid JSON.
        
          on /var/folders/6_/0g9n8_wn54b4df2znjp9ryc00000gn/T/tf-test656977397/main.tf line 2:
          (source code not available)
       
--- FAIL: TestAccDiscountCodeCreate_basic (0.29s)

from terraform-provider-commercetools.

RaniSputnik avatar RaniSputnik commented on July 23, 2024

I believe I've been able to further debug this issue. For me only the TestAccDiscountCodeCreate_basic is failing locally when I run make testacc, so that's what I've investigated.

I updated the following line to log the cart draft that is being created:

+               str, _ := json.Marshal(draft)
+		log.Printf("Creating discount code %s", str)
		discountCode, err = client.DiscountCodeCreate(draft)

That produces the following:

{"validUntil":"2021-01-02T15:04:05Z","validFrom":"2020-01-02T15:04:05Z","name":{"en":"Standard name"},"maxApplicationsPerCustomer":10,"maxApplications":100,"isActive":true,"description":{"en":"Standard description"},"code":"2","cartPredicate":"1=1","cartDiscounts":[{"typeId":"cart-discount","id":"cart-discount-id-0"},{"typeId":"cart-discount","id":"cart-discount-id-1"}]}

Feeding that into IMPEX resulted in the following error:

{
  "statusCode": 400,
  "message": "Request body does not contain valid JSON.",
  "errors": [
    {
      "code": "InvalidJsonInput",
      "message": "Request body does not contain valid JSON.",
      "detailedErrorMessage": "cartDiscounts -> id: Invalid UUID: 'cart-discount-id-0'"
    },
    {
      "code": "InvalidJsonInput",
      "message": "Request body does not contain valid JSON.",
      "detailedErrorMessage": "cartDiscounts -> id: Invalid UUID: 'cart-discount-id-1'"
    }
  ]
}

Making the following change in the testAccDiscountCodeConfig function results in a new error:

-cart_discounts = ["cart-discount-id-0", "cart-discount-id-1"]
+cart_discounts = ["ac5d0ae0-e650-4ddc-999b-c706d0271438", "73151624-0375-4c17-9f54-c738d2504265"]
TestAccDiscountCodeCreate_basic: testing.go:654: Step 0 error: errors during apply:
        
        Error: Cart Discount 'ac5d0ae0-e650-4ddc-999b-c706d0271438' doesn't exist.
        
          on /var/folders/v7/hnrvx86s6fsfpcyndw9gtj2h0000gq/T/tf-test283912456/main.tf line 2:
          (source code not available)

This looks like an easy fix but I'm not sure on the correct approach for this repo:

  • Do we add in the cart discount resources as a dependency of this acceptance test?
  • We're unable to remove the cart discounts as that also results in a 400.
  • Is there a separate setup step we can use to add known fixtures for acceptance tests?

I'm also unsure about fixing this, given that the acceptance tests are not run in CI (they're run against a mock server) - should we instead ensure these tests are run regularly to avoid any regression?

Let me know your thoughts on the above, I'm happy to open a PR for whichever strategy makes sense if I find some time.

from terraform-provider-commercetools.

qdegraaf avatar qdegraaf commented on July 23, 2024

Thanks for all the input. The tests in Cart Discount were fixed in #140 .

Full run now results in:

TF_ACC=1 go test -v ./...
?   	github.com/labd/terraform-provider-commercetools	[no test files]
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestAPIExtensionGetDestination
--- PASS: TestAPIExtensionGetDestination (0.00s)
=== RUN   TestAPIExtensionGetAuthentication
--- PASS: TestAPIExtensionGetAuthentication (0.00s)
=== RUN   TestAccAPIExtension_basic
--- PASS: TestAccAPIExtension_basic (1.27s)
=== RUN   TestAccCartDiscountCreate_basic
--- PASS: TestAccCartDiscountCreate_basic (1.15s)
=== RUN   TestAccCustomObjectCreate_basic
    testing.go:684: Step 1 error: Check failed: Check 4/4 error: commercetools_custom_object.test_number: Attribute 'version' expected "2", got "1"
--- FAIL: TestAccCustomObjectCreate_basic (0.19s)
=== RUN   TestAccCustomObjectCreate_object
--- PASS: TestAccCustomObjectCreate_object (0.10s)
=== RUN   TestAccCustomerGroupCreate_basic
--- PASS: TestAccCustomerGroupCreate_basic (1.17s)
=== RUN   TestAccDiscountCodeCreate_basic
--- PASS: TestAccDiscountCodeCreate_basic (1.19s)
=== RUN   TestAttributeTypeElement
--- PASS: TestAttributeTypeElement (0.00s)
=== RUN   TestGetAttributeType
--- PASS: TestGetAttributeType (0.00s)
=== RUN   TestAccProductTypes_basic
--- PASS: TestAccProductTypes_basic (0.70s)
=== RUN   TestAccProjectCreate_basic
--- PASS: TestAccProjectCreate_basic (0.96s)
=== RUN   TestAccShippingMethod_createAndUpdateWithID
--- PASS: TestAccShippingMethod_createAndUpdateWithID (0.85s)
=== RUN   TestAccShippingZoneRate_create
--- PASS: TestAccShippingZoneRate_create (0.67s)
=== RUN   TestAccShippingZone_createAndUpdateWithID
--- PASS: TestAccShippingZone_createAndUpdateWithID (0.57s)
=== RUN   TestAccShippingZone_createAndAddLocation
--- PASS: TestAccShippingZone_createAndAddLocation (0.70s)
=== RUN   TestAccShippingZone_createAndRemoveLocation
--- PASS: TestAccShippingZone_createAndRemoveLocation (1.00s)
=== RUN   TestAccState_createAndUpdateWithID
--- PASS: TestAccState_createAndUpdateWithID (1.58s)
=== RUN   TestAccStore_createAndUpdateWithID
--- PASS: TestAccStore_createAndUpdateWithID (0.98s)
=== RUN   TestAccStore_createAndUpdateDistributionLanguages
--- PASS: TestAccStore_createAndUpdateDistributionLanguages (1.17s)
=== RUN   TestValidateDestination
--- PASS: TestValidateDestination (0.00s)
=== RUN   TestAccSubscription_basic
--- PASS: TestAccSubscription_basic (20.04s)
=== RUN   TestAccTaxCategoryRate_createAndUpdateWithID
--- PASS: TestAccTaxCategoryRate_createAndUpdateWithID (1.19s)
=== RUN   TestAccTaxCategoryRate_createAndUpdateSubRates
--- PASS: TestAccTaxCategoryRate_createAndUpdateSubRates (0.85s)
=== RUN   TestAccTaxCategoryRate_createAndUpdateBothRateAndTaxCategory
--- PASS: TestAccTaxCategoryRate_createAndUpdateBothRateAndTaxCategory (0.92s)
=== RUN   TestAccTaxCategory_createAndUpdateWithID
--- PASS: TestAccTaxCategory_createAndUpdateWithID (0.60s)
=== RUN   TestFieldTypeElement
--- PASS: TestFieldTypeElement (0.00s)
=== RUN   TestResourceTypeGetFieldDefinition
--- PASS: TestResourceTypeGetFieldDefinition (0.00s)
=== RUN   TestGetFieldType
--- PASS: TestGetFieldType (0.00s)
=== RUN   TestAccTypes_basic
--- PASS: TestAccTypes_basic (0.41s)
=== RUN   TestAccTypes_UpdateWithID
--- PASS: TestAccTypes_UpdateWithID (0.85s)
=== RUN   TestCreateLookup
--- PASS: TestCreateLookup (0.00s)
FAIL
FAIL	github.com/labd/terraform-provider-commercetools/commercetools	39.444s
FAIL
make: *** [testacc] Error 1

The error in TestAccCustomObjectCreate_Basic is caused by #139 . This still needs to be picked up

Results of make testacc can still be inconsistent however, with the occasional trailing resource requiring manual deletion of created objects in commercetools to run right.

Keeping this issue open as there are still problems with acceptance tests that need some work.

from terraform-provider-commercetools.

mvantellingen avatar mvantellingen commented on July 23, 2024

This should work nowadays

from terraform-provider-commercetools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.