INNER CODE UNIT · Go

createTimeout

dikhan/terraform-provider-openapi · openapi/common_test.go:25

		createTimeout := 1 * time.Second
		resourceName := "cdn_v1"
		Convey("When crudWithContext is called", func() {
			contextAwareFunc := crudWithContext(stubCreateFunction, schema.TimeoutCreate, resourceName)
			Convey("Then the returned function which is context aware should not timeout and return an empty diagnosis", func() {
				ctx := context.Background()
				ctx, cancel := context.WithTimeout(ctx, createTimeout)
				defer cancel()
				diagnosis := contextAwareFunc(ctx, &schema.ResourceData{}, nil)
				So(diagnosis, ShouldBeEmpty)
			})
		})
	})
	Convey("Given a create function (which returns an error), a create timeout and a resource name", t, func() {
		expectedError := "some error"
		stubCreateFunction := func(data *schema.ResourceData, i interface{}) error {
			return errors.New(expectedError)
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…