diff --git a/.test-coverage b/.test-coverage index 8bb6ae1..045ec05 100755 --- a/.test-coverage +++ b/.test-coverage @@ -9,7 +9,7 @@ FAIL=0 for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d); do if ls $dir/*.go &> /dev/null; then - go test -v -covermode=count -coverprofile=profile.tmp $dir || FAIL=$? + go test -p 1 -v -covermode=count -coverprofile=profile.tmp $dir || FAIL=$? if [ -f profile.tmp ] then tail -n +2 < profile.tmp >> profile.cov diff --git a/cmd/stock/main.go b/cmd/stock/main.go index 5139cc7..b4cdc89 100644 --- a/cmd/stock/main.go +++ b/cmd/stock/main.go @@ -15,6 +15,7 @@ import ( "github.com/genofire/hs_master-kss-monolith/lib/database" "github.com/genofire/hs_master-kss-monolith/lib/log" "github.com/genofire/hs_master-kss-monolith/models" + "github.com/genofire/hs_master-kss-monolith/runtime" ) var ( @@ -29,7 +30,7 @@ func main() { // load config config = models.ReadConfigFile(configFile) web.GoodAvailablityTemplate = config.GoodAvailablityTemplate - models.CacheConfig = config.CacheClean + runtime.CacheConfig = config.CacheClean log.Log.Info("Starting rezension monolith") @@ -37,8 +38,8 @@ func main() { if err != nil { log.Log.Panic(err) } - grw := models.NewGoodReleaseWorker(config.GoodRelease) - cw := models.NewCacheWorker() + grw := runtime.NewGoodReleaseWorker(config.GoodRelease) + cw := runtime.NewCacheWorker() go grw.Start() go cw.Start() // Startwebsrver diff --git a/http/good.go b/http/good.go index f72b24d..3587d53 100644 --- a/http/good.go +++ b/http/good.go @@ -11,6 +11,7 @@ import ( lib "github.com/genofire/hs_master-kss-monolith/lib/http" logger "github.com/genofire/hs_master-kss-monolith/lib/log" "github.com/genofire/hs_master-kss-monolith/models" + "github.com/genofire/hs_master-kss-monolith/runtime" ) func listGoods(w http.ResponseWriter, r *http.Request) { @@ -42,7 +43,7 @@ func getGoodAvailablityCount(w http.ResponseWriter, r *http.Request) (int, *logr return -1, log } log = log.WithField("productid", id) - product := models.Product{ID: id} + product := runtime.Product{ID: id} ok, err := product.Exists() if err != nil { log.Warn("product could not verified on other microservice") diff --git a/http/good_test.go b/http/good_test.go index 7ecae54..f10cf5f 100644 --- a/http/good_test.go +++ b/http/good_test.go @@ -8,6 +8,7 @@ import ( "github.com/genofire/hs_master-kss-monolith/lib/database" "github.com/genofire/hs_master-kss-monolith/models" + "github.com/genofire/hs_master-kss-monolith/runtime" "github.com/genofire/hs_master-kss-monolith/test" ) @@ -84,14 +85,12 @@ func TestGetGoodAvailable(t *testing.T) { assertion.Equal(http.StatusNotFound, w.StatusCode) test.CloseServer() - - models.CacheConfig.After = models.Duration{Duration: time.Duration(5) * time.Millisecond} + runtime.CacheConfig.After = models.Duration{Duration: time.Duration(5) * time.Millisecond} time.Sleep(time.Duration(10) * time.Millisecond) - models.CleanCache() + runtime.CleanCache() result, w = session.JSONRequest("GET", "/api/good/availablity/3", nil) assertion.Equal(http.StatusGatewayTimeout, w.StatusCode) - test.Close() } diff --git a/lib/database/main.go b/lib/database/main.go index 8a7e2f0..ab2fe38 100644 --- a/lib/database/main.go +++ b/lib/database/main.go @@ -12,7 +12,7 @@ var ( Write *gorm.DB Read *gorm.DB config *Config - models []interface{} + runtime []interface{} ) type Config struct { @@ -48,7 +48,7 @@ func Open(c Config) (err error) { } else { Read = Write } - Write.AutoMigrate(models...) + Write.AutoMigrate(runtime...) return } @@ -62,5 +62,5 @@ func Close() { } func AddModel(m interface{}) { - models = append(models, m) + runtime = append(runtime, m) } diff --git a/models/config.go b/models/config.go index 15b1699..98b1109 100644 --- a/models/config.go +++ b/models/config.go @@ -19,6 +19,16 @@ type Config struct { CacheClean CacheWorkerConfig `toml:"cache_clean"` } +type CacheWorkerConfig struct { + Every Duration + After Duration +} + +type GoodReleaseConfig struct { + After Duration `toml:"after"` + Every Duration `toml:"every"` +} + // ReadConfigFile reads a config model from path of a yml file func ReadConfigFile(path string) *Config { config := &Config{} diff --git a/models/good_release.go b/models/good_release.go deleted file mode 100644 index 0543e90..0000000 --- a/models/good_release.go +++ /dev/null @@ -1,24 +0,0 @@ -package models - -import ( - "time" - - "github.com/genofire/hs_master-kss-monolith/lib/database" - "github.com/genofire/hs_master-kss-monolith/lib/worker" -) - -type GoodReleaseConfig struct { - After Duration `toml:"after"` - Every Duration `toml:"every"` -} - -func NewGoodReleaseWorker(grc GoodReleaseConfig) *worker.Worker { - return worker.NewWorker(grc.Every.Duration, func() { - goodRelease(grc.After.Duration) - }) -} - -func goodRelease(unlockAfter time.Duration) int64 { - res := database.Write.Model(&Good{}).Where("locked_secret is not NULL and locked_at < ?", time.Now().Add(-unlockAfter)).Updates(map[string]interface{}{"locked_secret": "", "locked_at": nil}) - return res.RowsAffected -} diff --git a/models/good_test.go b/models/good_test.go index af4e238..a020537 100644 --- a/models/good_test.go +++ b/models/good_test.go @@ -10,6 +10,12 @@ import ( func TestGood(t *testing.T) { assert := assert.New(t) + database.Open(database.Config{ + Type: "sqlite3", + Logging: true, + Connection: ":memory:", + }) + good := &Good{} assert.False(good.IsLock()) diff --git a/profile.cov b/profile.cov index 7be0896..527d82a 100644 --- a/profile.cov +++ b/profile.cov @@ -1,38 +1,4 @@ mode: count -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:10.59,11.49 1 0 -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:11.49,13.47 1 0 -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:19.3,19.45 1 0 -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:13.47,14.69 1 0 -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:14.69,16.5 1 0 -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:19.45,20.69 1 0 -github.com/genofire/hs_master-kss-monolith/models/cache_worker.go:20.69,22.5 1 0 -github.com/genofire/hs_master-kss-monolith/models/worker.go:11.59,18.2 2 1 -github.com/genofire/hs_master-kss-monolith/models/worker.go:20.26,22.6 2 1 -github.com/genofire/hs_master-kss-monolith/models/worker.go:22.6,23.10 1 6 -github.com/genofire/hs_master-kss-monolith/models/worker.go:24.19,25.11 1 5 -github.com/genofire/hs_master-kss-monolith/models/worker.go:26.17,28.10 2 1 -github.com/genofire/hs_master-kss-monolith/models/worker.go:32.26,34.2 1 1 -github.com/genofire/hs_master-kss-monolith/models/good_release.go:14.58,15.46 1 1 -github.com/genofire/hs_master-kss-monolith/models/good_release.go:15.46,17.3 1 5 -github.com/genofire/hs_master-kss-monolith/models/good_release.go:20.51,23.2 2 7 -github.com/genofire/hs_master-kss-monolith/models/product_cache.go:21.13,23.2 1 1 -github.com/genofire/hs_master-kss-monolith/models/product_cache.go:25.42,26.46 1 2 -github.com/genofire/hs_master-kss-monolith/models/product_cache.go:34.2,42.43 5 1 -github.com/genofire/hs_master-kss-monolith/models/product_cache.go:26.46,29.38 2 1 -github.com/genofire/hs_master-kss-monolith/models/product_cache.go:29.38,31.4 1 1 -github.com/genofire/hs_master-kss-monolith/models/auth.go:27.81,29.39 2 1 -github.com/genofire/hs_master-kss-monolith/models/auth.go:37.2,45.36 5 1 -github.com/genofire/hs_master-kss-monolith/models/auth.go:29.39,32.38 2 0 -github.com/genofire/hs_master-kss-monolith/models/auth.go:32.38,34.4 1 0 -github.com/genofire/hs_master-kss-monolith/models/auth.go:50.13,52.2 1 1 -github.com/genofire/hs_master-kss-monolith/models/auth.go:54.64,56.9 2 1 -github.com/genofire/hs_master-kss-monolith/models/auth.go:63.2,63.50 1 1 -github.com/genofire/hs_master-kss-monolith/models/auth.go:56.9,62.3 1 1 -github.com/genofire/hs_master-kss-monolith/models/config.go:22.42,25.16 3 3 -github.com/genofire/hs_master-kss-monolith/models/config.go:29.2,29.53 1 2 -github.com/genofire/hs_master-kss-monolith/models/config.go:33.2,33.15 1 1 -github.com/genofire/hs_master-kss-monolith/models/config.go:25.16,27.3 1 1 -github.com/genofire/hs_master-kss-monolith/models/config.go:29.53,31.3 1 1 github.com/genofire/hs_master-kss-monolith/models/duration.go:19.67,21.30 2 20 github.com/genofire/hs_master-kss-monolith/models/duration.go:28.2,28.19 1 19 github.com/genofire/hs_master-kss-monolith/models/duration.go:32.2,34.16 3 18 @@ -56,6 +22,11 @@ github.com/genofire/hs_master-kss-monolith/models/good.go:40.44,41.30 1 2 github.com/genofire/hs_master-kss-monolith/models/good.go:46.2,46.35 1 1 github.com/genofire/hs_master-kss-monolith/models/good.go:41.30,45.3 3 1 github.com/genofire/hs_master-kss-monolith/models/good.go:49.13,51.2 1 1 +github.com/genofire/hs_master-kss-monolith/models/config.go:33.42,36.16 3 3 +github.com/genofire/hs_master-kss-monolith/models/config.go:40.2,40.53 1 2 +github.com/genofire/hs_master-kss-monolith/models/config.go:44.2,44.15 1 1 +github.com/genofire/hs_master-kss-monolith/models/config.go:36.16,38.3 1 1 +github.com/genofire/hs_master-kss-monolith/models/config.go:40.53,42.3 1 1 github.com/genofire/hs_master-kss-monolith/lib/log/main.go:14.13,18.2 2 1 github.com/genofire/hs_master-kss-monolith/lib/log/main.go:21.42,23.18 2 1 github.com/genofire/hs_master-kss-monolith/lib/log/main.go:26.2,30.4 1 1 @@ -72,32 +43,70 @@ github.com/genofire/hs_master-kss-monolith/lib/database/main.go:55.14,58.36 3 2 github.com/genofire/hs_master-kss-monolith/lib/database/main.go:61.2,61.12 1 2 github.com/genofire/hs_master-kss-monolith/lib/database/main.go:58.36,60.3 1 1 github.com/genofire/hs_master-kss-monolith/lib/database/main.go:64.30,66.2 1 2 -github.com/genofire/hs_master-kss-monolith/lib/http/main.go:10.56,11.56 1 2 -github.com/genofire/hs_master-kss-monolith/lib/http/main.go:15.2,16.8 2 1 -github.com/genofire/hs_master-kss-monolith/lib/http/main.go:11.56,14.3 2 1 -github.com/genofire/hs_master-kss-monolith/lib/http/main.go:20.53,22.16 2 2 -github.com/genofire/hs_master-kss-monolith/lib/http/main.go:26.2,27.13 2 1 -github.com/genofire/hs_master-kss-monolith/lib/http/main.go:22.16,25.3 2 1 -github.com/genofire/hs_master-kss-monolith/http/main.go:8.32,12.2 3 3 -github.com/genofire/hs_master-kss-monolith/http/status.go:12.53,31.2 8 1 -github.com/genofire/hs_master-kss-monolith/http/good.go:16.56,19.16 3 3 -github.com/genofire/hs_master-kss-monolith/http/good.go:24.2,27.30 4 2 -github.com/genofire/hs_master-kss-monolith/http/good.go:32.2,33.18 2 1 -github.com/genofire/hs_master-kss-monolith/http/good.go:19.16,23.3 3 1 -github.com/genofire/hs_master-kss-monolith/http/good.go:27.30,31.3 3 1 -github.com/genofire/hs_master-kss-monolith/http/good.go:36.91,39.16 3 4 -github.com/genofire/hs_master-kss-monolith/http/good.go:44.2,47.16 4 3 -github.com/genofire/hs_master-kss-monolith/http/good.go:51.2,51.9 1 3 -github.com/genofire/hs_master-kss-monolith/http/good.go:56.2,58.24 3 3 -github.com/genofire/hs_master-kss-monolith/http/good.go:39.16,43.3 3 1 -github.com/genofire/hs_master-kss-monolith/http/good.go:47.16,50.3 2 0 -github.com/genofire/hs_master-kss-monolith/http/good.go:51.9,55.3 3 0 -github.com/genofire/hs_master-kss-monolith/http/good.go:60.65,62.15 2 4 -github.com/genofire/hs_master-kss-monolith/http/good.go:65.2,66.38 2 3 -github.com/genofire/hs_master-kss-monolith/http/good.go:72.2,72.18 1 3 -github.com/genofire/hs_master-kss-monolith/http/good.go:62.15,64.3 1 1 -github.com/genofire/hs_master-kss-monolith/http/good.go:67.26,68.22 1 2 -github.com/genofire/hs_master-kss-monolith/http/good.go:69.10,70.34 1 1 +github.com/genofire/hs_master-kss-monolith/lib/worker/worker.go:11.59,18.2 2 1 +github.com/genofire/hs_master-kss-monolith/lib/worker/worker.go:20.26,22.6 2 1 +github.com/genofire/hs_master-kss-monolith/lib/worker/worker.go:22.6,23.10 1 4 +github.com/genofire/hs_master-kss-monolith/lib/worker/worker.go:24.19,25.11 1 3 +github.com/genofire/hs_master-kss-monolith/lib/worker/worker.go:26.17,28.10 2 1 +github.com/genofire/hs_master-kss-monolith/lib/worker/worker.go:32.26,34.2 1 1 +github.com/genofire/hs_master-kss-monolith/lib/http/io.go:10.56,11.56 1 2 +github.com/genofire/hs_master-kss-monolith/lib/http/io.go:15.2,16.8 2 1 +github.com/genofire/hs_master-kss-monolith/lib/http/io.go:11.56,14.3 2 1 +github.com/genofire/hs_master-kss-monolith/lib/http/io.go:20.53,22.16 2 2 +github.com/genofire/hs_master-kss-monolith/lib/http/io.go:26.2,27.13 2 1 +github.com/genofire/hs_master-kss-monolith/lib/http/io.go:22.16,25.3 2 1 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:7.153,8.54 1 4 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:8.54,10.17 2 4 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:14.3,15.17 2 3 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:19.3,19.9 1 2 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:23.3,23.53 1 1 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:10.17,13.4 2 1 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:15.17,18.4 2 1 +github.com/genofire/hs_master-kss-monolith/lib/http/permission.go:19.9,22.4 2 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:17.56,20.16 3 3 +github.com/genofire/hs_master-kss-monolith/http/good.go:25.2,28.30 4 2 +github.com/genofire/hs_master-kss-monolith/http/good.go:33.2,34.18 2 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:20.16,24.3 3 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:28.30,32.3 3 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:37.91,40.16 3 6 +github.com/genofire/hs_master-kss-monolith/http/good.go:45.2,48.16 4 5 +github.com/genofire/hs_master-kss-monolith/http/good.go:53.2,53.9 1 4 +github.com/genofire/hs_master-kss-monolith/http/good.go:58.2,60.24 3 3 +github.com/genofire/hs_master-kss-monolith/http/good.go:40.16,44.3 3 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:48.16,52.3 3 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:53.9,57.3 3 1 +github.com/genofire/hs_master-kss-monolith/http/good.go:62.65,64.15 2 6 +github.com/genofire/hs_master-kss-monolith/http/good.go:67.2,68.38 2 3 +github.com/genofire/hs_master-kss-monolith/http/good.go:74.2,74.18 1 3 +github.com/genofire/hs_master-kss-monolith/http/good.go:64.15,66.3 1 3 +github.com/genofire/hs_master-kss-monolith/http/good.go:69.26,70.22 1 2 +github.com/genofire/hs_master-kss-monolith/http/good.go:71.10,72.34 1 1 github.com/genofire/hs_master-kss-monolith/http/good_temp.go:13.38,15.2 1 1 github.com/genofire/hs_master-kss-monolith/http/good_temp.go:17.56,19.2 1 1 github.com/genofire/hs_master-kss-monolith/http/good_temp.go:21.62,37.2 10 1 +github.com/genofire/hs_master-kss-monolith/http/main.go:8.32,12.2 3 3 +github.com/genofire/hs_master-kss-monolith/http/status.go:12.53,31.2 8 1 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:27.81,29.39 2 2 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:36.2,44.36 5 1 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:29.39,31.36 2 1 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:31.36,33.4 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:49.13,51.2 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:53.64,55.9 2 2 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:62.2,62.50 1 2 +github.com/genofire/hs_master-kss-monolith/runtime/auth.go:55.9,61.3 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:12.19,15.46 2 4 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:21.2,21.44 1 4 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:15.46,16.36 1 2 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:16.36,18.4 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:21.44,22.36 1 4 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:22.36,24.4 1 2 +github.com/genofire/hs_master-kss-monolith/runtime/cache_worker.go:27.42,29.2 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/good_release.go:11.72,12.53 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/good_release.go:12.53,14.3 1 5 +github.com/genofire/hs_master-kss-monolith/runtime/good_release.go:17.51,20.2 2 7 +github.com/genofire/hs_master-kss-monolith/runtime/product_cache.go:21.13,23.2 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/product_cache.go:25.42,26.46 1 2 +github.com/genofire/hs_master-kss-monolith/runtime/product_cache.go:30.2,33.16 4 1 +github.com/genofire/hs_master-kss-monolith/runtime/product_cache.go:39.2,39.43 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/product_cache.go:26.46,28.3 1 1 +github.com/genofire/hs_master-kss-monolith/runtime/product_cache.go:33.16,38.3 1 1 diff --git a/models/auth.go b/runtime/auth.go similarity index 98% rename from models/auth.go rename to runtime/auth.go index 3eb4b25..56403b3 100644 --- a/models/auth.go +++ b/runtime/auth.go @@ -1,4 +1,4 @@ -package models +package runtime import ( "fmt" diff --git a/models/auth_test.go b/runtime/auth_test.go similarity index 96% rename from models/auth_test.go rename to runtime/auth_test.go index adc15f9..b5dac2f 100644 --- a/models/auth_test.go +++ b/runtime/auth_test.go @@ -1,4 +1,4 @@ -package models +package runtime import ( "net/http" diff --git a/models/cache_worker.go b/runtime/cache_worker.go similarity index 83% rename from models/cache_worker.go rename to runtime/cache_worker.go index 717566c..868b4d4 100644 --- a/models/cache_worker.go +++ b/runtime/cache_worker.go @@ -1,17 +1,13 @@ -package models +package runtime import ( "time" "github.com/genofire/hs_master-kss-monolith/lib/worker" + "github.com/genofire/hs_master-kss-monolith/models" ) -var CacheConfig CacheWorkerConfig - -type CacheWorkerConfig struct { - Every Duration - After Duration -} +var CacheConfig models.CacheWorkerConfig func CleanCache() { before := time.Now().Add(-CacheConfig.After.Duration) diff --git a/models/cache_worker_test.go b/runtime/cache_worker_test.go similarity index 62% rename from models/cache_worker_test.go rename to runtime/cache_worker_test.go index 046a761..629d133 100644 --- a/models/cache_worker_test.go +++ b/runtime/cache_worker_test.go @@ -1,8 +1,10 @@ -package models +package runtime import ( "testing" "time" + + "github.com/genofire/hs_master-kss-monolith/models" ) func TestCacheWorker(t *testing.T) { @@ -13,9 +15,9 @@ func TestCacheWorker(t *testing.T) { session: "blub", permissions: make(map[Permission]boolMicroServiceCache), } - CacheConfig = CacheWorkerConfig{ - Every: Duration{Duration: time.Duration(3) * time.Millisecond}, - After: Duration{Duration: time.Duration(5) * time.Millisecond}, + CacheConfig = models.CacheWorkerConfig{ + Every: models.Duration{Duration: time.Duration(3) * time.Millisecond}, + After: models.Duration{Duration: time.Duration(5) * time.Millisecond}, } cw := NewCacheWorker() go cw.Start() diff --git a/runtime/good_release.go b/runtime/good_release.go new file mode 100644 index 0000000..723a2cd --- /dev/null +++ b/runtime/good_release.go @@ -0,0 +1,20 @@ +package runtime + +import ( + "time" + + "github.com/genofire/hs_master-kss-monolith/lib/database" + "github.com/genofire/hs_master-kss-monolith/lib/worker" + "github.com/genofire/hs_master-kss-monolith/models" +) + +func NewGoodReleaseWorker(grc models.GoodReleaseConfig) *worker.Worker { + return worker.NewWorker(grc.Every.Duration, func() { + goodRelease(grc.After.Duration) + }) +} + +func goodRelease(unlockAfter time.Duration) int64 { + res := database.Write.Model(&models.Good{}).Where("locked_secret is not NULL and locked_at < ?", time.Now().Add(-unlockAfter)).Updates(map[string]interface{}{"locked_secret": "", "locked_at": nil}) + return res.RowsAffected +} diff --git a/models/good_release_test.go b/runtime/good_release_test.go similarity index 73% rename from models/good_release_test.go rename to runtime/good_release_test.go index 24989cd..bd557a7 100644 --- a/models/good_release_test.go +++ b/runtime/good_release_test.go @@ -1,4 +1,4 @@ -package models +package runtime import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/genofire/hs_master-kss-monolith/lib/database" + "github.com/genofire/hs_master-kss-monolith/models" ) func TestGoodRelease(t *testing.T) { @@ -17,7 +18,7 @@ func TestGoodRelease(t *testing.T) { Connection: ":memory:", }) now := time.Now() - good := Good{ + good := models.Good{ LockedAt: &now, LockedSecret: "never used", } @@ -31,9 +32,9 @@ func TestGoodRelease(t *testing.T) { count = goodRelease(time.Duration(3) * time.Second) assert.Equal(int64(1), count, "unlock after timeout") - grw := NewGoodReleaseWorker(GoodReleaseConfig{ - Every: Duration{Duration: time.Duration(3) * time.Millisecond}, - After: Duration{Duration: time.Duration(5) * time.Millisecond}, + grw := NewGoodReleaseWorker(models.GoodReleaseConfig{ + Every: models.Duration{Duration: time.Duration(3) * time.Millisecond}, + After: models.Duration{Duration: time.Duration(5) * time.Millisecond}, }) go grw.Start() time.Sleep(time.Duration(15) * time.Millisecond) diff --git a/models/product.go b/runtime/product.go similarity index 68% rename from models/product.go rename to runtime/product.go index 5199b0c..58e9b6f 100644 --- a/models/product.go +++ b/runtime/product.go @@ -1,4 +1,4 @@ -package models +package runtime type Product struct { ID int64 diff --git a/models/product_cache.go b/runtime/product_cache.go similarity index 98% rename from models/product_cache.go rename to runtime/product_cache.go index e6ef414..0c38704 100644 --- a/models/product_cache.go +++ b/runtime/product_cache.go @@ -1,4 +1,4 @@ -package models +package runtime import ( "fmt" diff --git a/models/product_test.go b/runtime/product_test.go similarity index 96% rename from models/product_test.go rename to runtime/product_test.go index acc7660..30ea302 100644 --- a/models/product_test.go +++ b/runtime/product_test.go @@ -1,4 +1,4 @@ -package models +package runtime import ( "net/http"