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

40 lines
848 B
Go
Raw Normal View History

2017-05-03 08:02:29 +02:00
// Package with supporting functionality to run the microservice
package runtime
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
2017-05-03 08:02:29 +02:00
// Function to test, if and which products exist (get information from the products catalogue)
func TestProductExists(t *testing.T) {
assert := assert.New(t)
2017-04-04 08:18:58 +02:00
ProductURL = "http://localhost:8080/api-test/product/%d/"
router := http.FileServer(http.Dir("../webroot"))
srv := &http.Server{
Addr: ":8080",
Handler: router,
}
go srv.ListenAndServe()
2017-05-05 10:56:03 +02:00
ok, err := ProductExists(3)
2017-04-04 08:18:58 +02:00
assert.True(ok)
assert.NoError(err)
2017-04-04 08:18:58 +02:00
// test cache
2017-05-05 10:56:03 +02:00
ok, err = ProductExists(3)
assert.True(ok)
assert.NoError(err)
2017-04-04 08:18:58 +02:00
productExistCache = make(map[int64]boolMicroServiceCache)
ProductURL = "http://localhost:8081/api-test/product/%d/"
2017-05-05 10:56:03 +02:00
ok, err = ProductExists(3)
assert.Error(err)
srv.Close()
}