go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/kana-server/pkg/types/quiz_test.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package types_test 9 10 import ( 11 "testing" 12 "time" 13 14 "go.charczuk.com/sdk/assert" 15 16 "go.charczuk.com/projects/kana-server/pkg/types" 17 ) 18 19 func Test_Quiz_PromptStats(t *testing.T) { 20 q := types.Quiz{ 21 Results: []types.QuizResult{ 22 { // 23 Prompt: "p0", 24 Expected: "pa0", 25 Actual: "pa0", 26 CreatedUTC: time.Now().UTC(), 27 AnsweredUTC: time.Now().UTC().Add(time.Second), 28 }, 29 { // 30 Prompt: "p1", 31 Expected: "pa1", 32 Actual: "pa1", 33 CreatedUTC: time.Now().UTC(), 34 AnsweredUTC: time.Now().UTC().Add(2 * time.Second), 35 }, 36 { // 37 Prompt: "p2", 38 Expected: "pa2", 39 Actual: "pa2", 40 CreatedUTC: time.Now().UTC(), 41 AnsweredUTC: time.Now().UTC().Add(3 * time.Second), 42 }, 43 { // 44 Prompt: "p0", 45 Expected: "pa0", 46 Actual: "npa0", 47 CreatedUTC: time.Now().UTC(), 48 AnsweredUTC: time.Now().UTC().Add(2 * time.Second), 49 }, 50 { // 51 Prompt: "p1", 52 Expected: "pa1", 53 Actual: "pa1", 54 CreatedUTC: time.Now().UTC(), 55 AnsweredUTC: time.Now().UTC().Add(3 * time.Second), 56 }, 57 { // 58 Prompt: "p2", 59 Expected: "pa2", 60 Actual: "pa2", 61 CreatedUTC: time.Now().UTC(), 62 AnsweredUTC: time.Now().UTC().Add(time.Second), 63 }, 64 { // 65 Prompt: "p1", 66 Expected: "pa1", 67 Actual: "pa1", 68 CreatedUTC: time.Now().UTC(), 69 AnsweredUTC: time.Now().UTC().Add(time.Second), 70 }, 71 }, 72 } 73 74 ps := q.PromptStats() 75 assert.ItsLen(t, ps, 3) 76 }