genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/runtime/productcache_test.go

38 lines
849 B
Go

// Package with supporting functionality to run the microservice
package runtime
import (
"net/http"
"testing"
"github.com/genofire/hs_master-kss-monolith/test"
"github.com/stretchr/testify/assert"
)
// Function to test, if and which products exist (get information from the products catalogue)
func TestProductExists(t *testing.T) {
assert := assert.New(t)
ProductURL = "http://localhost:8080/api-test/product/%d/"
router := http.FileServer(http.Dir("../webroot"))
mock := test.MockTransport{Handler: router}
http.DefaultClient.Transport = &mock
mock.Start()
ok, err := ProductExists(3)
assert.True(ok)
assert.NoError(err)
// test cache
ok, err = ProductExists(3)
assert.True(ok)
assert.NoError(err)
mock.Close()
productExistCache = make(map[int64]boolMicroServiceCache)
ok, err = ProductExists(3)
assert.Error(err)
}