MCPcopy Index your code
hub / github.com/coder/coder / TestResolveUserCompactionThreshold

Function TestResolveUserCompactionThreshold

coderd/x/chatd/chatd_internal_test.go:2984–3061  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2982}
2983
2984func TestResolveUserCompactionThreshold(t *testing.T) {
2985 t.Parallel()
2986
2987 userID := uuid.New()
2988 modelConfigID := uuid.New()
2989 expectedKey := codersdk.CompactionThresholdKey(modelConfigID)
2990
2991 tests := []struct {
2992 name string
2993 dbReturn string
2994 dbErr error
2995 wantVal int32
2996 wantOK bool
2997 wantWarnLog bool
2998 }{
2999 {
3000 name: "NoRowsReturnsDefault",
3001 dbErr: sql.ErrNoRows,
3002 wantOK: false,
3003 },
3004 {
3005 name: "ValidOverride",
3006 dbReturn: "75",
3007 wantVal: 75,
3008 wantOK: true,
3009 },
3010 {
3011 name: "OutOfRangeValue",
3012 dbReturn: "101",
3013 wantOK: false,
3014 },
3015 {
3016 name: "NonIntegerValue",
3017 dbReturn: "abc",
3018 wantOK: false,
3019 },
3020 {
3021 name: "UnexpectedDBError",
3022 dbErr: xerrors.New("connection refused"),
3023 wantOK: false,
3024 wantWarnLog: true,
3025 },
3026 }
3027
3028 for _, tc := range tests {
3029 tc := tc
3030 t.Run(tc.name, func(t *testing.T) {
3031 t.Parallel()
3032
3033 ctrl := gomock.NewController(t)
3034 mockDB := dbmock.NewMockStore(ctrl)
3035 sink := testutil.NewFakeSink(t)
3036
3037 srv := &Server{
3038 db: mockDB,
3039 logger: sink.Logger(),
3040 }
3041

Callers

nothing calls this directly

Calls 13

LoggerMethod · 0.95
EXPECTMethod · 0.95
EntriesMethod · 0.95
CompactionThresholdKeyFunction · 0.92
NewMockStoreFunction · 0.92
NewFakeSinkFunction · 0.92
NotEmptyMethod · 0.80
NewMethod · 0.65
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected