MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / TestGetBuffSpec

Function TestGetBuffSpec

internal/buffs/buffspec_test.go:144–199  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

142 }
143}
144func TestGetBuffSpec(t *testing.T) {
145 // Save and restore original buffs map
146 origBuffs := buffs
147 defer func() { buffs = origBuffs }()
148
149 // Setup test buffs
150 buffs = map[int]*BuffSpec{
151 1: {BuffId: 1, Name: "Test Buff 1"},
152 2: {BuffId: 2, Name: "Test Buff 2"},
153 }
154
155 tests := []struct {
156 name string
157 inputId int
158 wantBuff *BuffSpec
159 wantFound bool
160 }{
161 {
162 name: "Existing positive buffId",
163 inputId: 1,
164 wantBuff: &BuffSpec{BuffId: 1, Name: "Test Buff 1"},
165 wantFound: true,
166 },
167 {
168 name: "Existing negative buffId (should convert to positive)",
169 inputId: -2,
170 wantBuff: &BuffSpec{BuffId: 2, Name: "Test Buff 2"},
171 wantFound: true,
172 },
173 {
174 name: "Non-existing buffId",
175 inputId: 99,
176 wantBuff: nil,
177 wantFound: false,
178 },
179 {
180 name: "Non-existing negative buffId",
181 inputId: -99,
182 wantBuff: nil,
183 wantFound: false,
184 },
185 }
186
187 for _, tt := range tests {
188 t.Run(tt.name, func(t *testing.T) {
189 got := GetBuffSpec(tt.inputId)
190 if tt.wantFound {
191 assert.NotNil(t, got)
192 assert.Equal(t, tt.wantBuff.BuffId, got.BuffId)
193 assert.Equal(t, tt.wantBuff.Name, got.Name)
194 } else {
195 assert.Nil(t, got)
196 }
197 })
198 }
199}
200func TestGetAllBuffIds(t *testing.T) {
201 origBuffs := buffs

Callers

nothing calls this directly

Calls 1

GetBuffSpecFunction · 0.85

Tested by

no test coverage detected