2022-09-03 13:13:04 +00:00
|
|
|
package joke_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
2023-08-12 05:36:08 +00:00
|
|
|
|
|
|
|
"jokes-bapak2-api/core/joke"
|
2022-09-03 13:13:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetTotalJoke(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
total, err := joke.GetTotalJoke(ctx, bucket, cache, memory)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if total != 5 {
|
|
|
|
t.Errorf("expecting total to be 5 instead got %d", total)
|
|
|
|
}
|
|
|
|
}
|