Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stumble committed Nov 9, 2022
1 parent 9d29b53 commit d26692a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 20 deletions.
6 changes: 6 additions & 0 deletions example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module github.com/stumble/needle/example
go 1.18

require (
github.com/coocood/freecache v1.2.2
github.com/go-redis/redis/v8 v8.11.5
github.com/stretchr/testify v1.8.0
github.com/stumble/needle-clients v0.4.0
)
Expand All @@ -11,6 +13,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
Expand All @@ -24,6 +27,9 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rs/zerolog v1.28.0 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
22 changes: 22 additions & 0 deletions example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/coocood/freecache v1.2.2 h1:UPkJCxhRujykq1jXuwxAPgDHnm6lKGrLZPnuHzgWRtE=
github.com/coocood/freecache v1.2.2/go.mod h1:RBUWa/Cy+OHdfTGFEhEuE1pMCMX51Ncizj7rthiQ3vk=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand All @@ -70,6 +75,8 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down Expand Up @@ -164,6 +171,9 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -200,20 +210,28 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stumble/needle-clients v0.4.0 h1:W+PyPpohf7huAMaew6tmJKMu+0AMrMlJC/HOJsWAoGw=
github.com/stumble/needle-clients v0.4.0/go.mod h1:obMOhuoG+/qtrC3/63bO0EULW9xHDzpvBhvO/R8BL1k=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -288,6 +306,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -355,6 +374,7 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -486,11 +506,13 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
44 changes: 31 additions & 13 deletions example/music.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package musicsrepo is generated by needle v0.4.1-2-g4941220-dirty, DO NOT CHANGE.
// Package musicsrepo is generated by needle v0.4.2-1-ga5cc79e-dirty, DO NOT CHANGE.
package musicsrepo

import (
Expand Down Expand Up @@ -178,11 +178,12 @@ func (s musics) GetMusics(ctx context.Context, options ...Option) ([]Music, erro
if s.cache == nil {
return s.getMusics(ctx, exec, args)
}
rst, err := s.cache.Get(ctx, args.Key(), ([]Music)(nil), time.Duration(5000000000),
rst := new([]Music)
err := s.cache.Get(ctx, args.Key(), rst, time.Duration(5000000000),
func() (interface{}, error) {
return s.getMusics(ctx, exec, args)
}, nocache)
return rst.([]Music), err
return *rst, err

}

Expand Down Expand Up @@ -241,11 +242,12 @@ func (s musics) Search(ctx context.Context, args *SearchArgs, options ...Option)
if s.cache == nil {
return s.search(ctx, exec, args)
}
rst, err := s.cache.Get(ctx, args.Key(), ([]Music)(nil), time.Duration(5000000000),
rst := new([]Music)
err := s.cache.Get(ctx, args.Key(), rst, time.Duration(5000000000),
func() (interface{}, error) {
return s.search(ctx, exec, args)
}, nocache)
return rst.([]Music), err
return *rst, err

}

Expand Down Expand Up @@ -304,11 +306,12 @@ func (s musics) ListMusicsLTSpotifyID(ctx context.Context, args *ListMusicsLTSpo
if s.cache == nil {
return s.listMusicsLTSpotifyID(ctx, exec, args)
}
rst, err := s.cache.Get(ctx, args.Key(), ([]Music)(nil), time.Duration(5000000000),
rst := new([]Music)
err := s.cache.Get(ctx, args.Key(), rst, time.Duration(5000000000),
func() (interface{}, error) {
return s.listMusicsLTSpotifyID(ctx, exec, args)
}, nocache)
return rst.([]Music), err
return *rst, err

}

Expand Down Expand Up @@ -370,12 +373,12 @@ func (s musics) GetMusicByAuthorAndName(ctx context.Context, args *GetMusicByAut
if s.cache == nil {
return s.getMusicByAuthorAndName(ctx, exec, args)
}
rst, err := s.cache.Get(ctx, args.Key(), (*Music)(nil), time.Duration(300000000000),
rst := new(*Music)
err := s.cache.Get(ctx, args.Key(), rst, time.Duration(300000000000),
func() (interface{}, error) {
return s.getMusicByAuthorAndName(ctx, exec, args)
}, nocache)

return rst.(*Music), err
return *rst, err

}

Expand Down Expand Up @@ -620,11 +623,26 @@ type PassThroughFunc = func() (interface{}, error)

// Cache is the interface that the cache layer must statisfy.
type Cache interface {
Get(ctx context.Context, key string, vtype interface{},
ttl time.Duration, f PassThroughFunc, noCache bool) (interface{}, error)

// Get returns value of f(). The value will be saved into target and
// cached in redis and inmemcache, if configured.
// Inputs:
// queryKey - key used in cache
// target - receive the cached value, must be pointer
// expire - expiration of cache key
// f - actual call that hits underlying data source
// noCache - whether force read from data source
Get(ctx context.Context, queryKey string, target interface{}, expire time.Duration, f PassThroughFunc, noCache bool) error

// Set explicitly set a cache key to a val
// Inputs:
// key - key to set
// val - val to set
// ttl - ttl of key
Set(ctx context.Context, key string, val interface{}, ttl time.Duration) error

// Invalidate explicitly invalidates a cache key
// Inputs:
// key - key to invalidate
Invalidate(ctx context.Context, key string) error
}

Expand Down
25 changes: 20 additions & 5 deletions example/music_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package musicsrepo
import (
"context"
"encoding/json"
"fmt"
"testing"
"time"

"github.com/coocood/freecache"
"github.com/go-redis/redis/v8"
"github.com/stretchr/testify/suite"

"github.com/stumble/needle-clients/dcache"
"github.com/stumble/needle-clients/mysql/testsuite"
)

Expand All @@ -21,8 +25,8 @@ type musicTableCodec struct {

func (m musicTableCodec) Dump() ([]byte, error) {
return m.repo.Dump(context.Background(), func(m *Music) {
m.CreatedAt = time.Unix(0, 0)
m.UpdatedAt = time.Unix(0, 0)
m.CreatedAt = time.Unix(0, 0).UTC()
m.UpdatedAt = time.Unix(0, 0).UTC()
})
}
func (m musicTableCodec) Load(data []byte) error {
Expand All @@ -31,7 +35,8 @@ func (m musicTableCodec) Load(data []byte) error {

type musicTestSuite struct {
testsuite.MysqlTestSuite
repo Musics
cache dcache.Cache
repo Musics
}

func TestMusicTestSuite(t *testing.T) {
Expand All @@ -43,8 +48,18 @@ func TestMusicTestSuite(t *testing.T) {
}

func (suite *musicTestSuite) SetupTest() {
// for consistent representation of time.
time.Local = time.UTC
suite.MysqlTestSuite.SetupTest()
suite.repo = NewMusics(nil, suite.Manager.GetExec())
redisClient := redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("127.0.0.1:6379"),
DB: 10,
})
inMemCache := freecache.NewCache(1024 * 1024)
cache, err := dcache.NewCache("music", redisClient, inMemCache, time.Millisecond)
suite.Require().NoError(err)
suite.cache = cache
suite.repo = NewMusics(cache, suite.Manager.GetExec())
}

func (suite *musicTestSuite) TestInsertUseGolden() {
Expand All @@ -54,7 +69,7 @@ func (suite *musicTestSuite) TestInsertUseGolden() {
Album: "Crazy ideas",
SpotifyID: 999,
DownloadPath: nil,
ReleasedAt: time.Unix(1000, 0),
ReleasedAt: time.Unix(1000, 0).UTC(),
}, nil, nil, nil, nil)
suite.Require().NoError(err)
suite.Golden("musics", musicTableCodec{repo: suite.repo})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"album": "Crazy ideas",
"spotify_id": 999,
"released_at": "1970-01-01T00:16:40Z",
"created_at": "1969-12-31T16:00:00-08:00",
"updated_at": "1969-12-31T16:00:00-08:00"
"created_at": "1970-01-01T00:00:00Z",
"updated_at": "1970-01-01T00:00:00Z"
}
]

0 comments on commit d26692a

Please sign in to comment.