diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..88c31e24 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +# Change these variables as necessary. +MAIN_PACKAGE_PATH := ./ +BINARY_NAME := terraform-provider-restapi +GO := go +GO_VERSION ?= 1.21 + +# ==================================================================================== # +# DEVELOPMENT +# ==================================================================================== # + +## test: run all tests +.PHONY: test +test: + bash ./scripts/set-local-testing.rc + bash ./scripts/test.sh + +## build: build the application +.PHONY: build +build: + # Include additional build steps compilation here... + $(GO) build -o=${BINARY_NAME}.o ${MAIN_PACKAGE_PATH} + +.PHONY: clean +clean : + rm ${BINARY_NAME}.o diff --git a/fakeserver/fakeserver.go b/fakeserver/fakeserver.go index 8a16a3d5..f22fa366 100644 --- a/fakeserver/fakeserver.go +++ b/fakeserver/fakeserver.go @@ -212,10 +212,20 @@ func (svr *Fakeserver) handleAPIObject(w http.ResponseWriter, r *http.Request) { } svr.objects[id] = obj - /* Coax the data we were sent back to JSON and send it to the user */ - b, _ := json.Marshal(obj) - w.Write(b) - return + /* Edge case to test a response from the server as not a JSON object */ + if val, ok := obj["No_json"]; ok { + if val == true { + log.Printf("fakeserver.go: Returning a non-JSON response\n") + b, _ := json.Marshal(obj["Id"]) + w.Write(b) + return + } + } else { + /* Coax the data we were sent back to JSON and send it to the user */ + b, _ := json.Marshal(obj) + w.Write(b) + return + } } /* No data was sent... must be just a retrieval */ if svr.debug {