MCPcopy
hub / github.com/perkeep/perkeep / TestAttribute

Function TestAttribute

pkg/schema/schema_test.go:237–340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

235}
236
237func TestAttribute(t *testing.T) {
238 tm := time.Unix(123, 456)
239 br := blob.MustParse("xxx-1234")
240 tests := []struct {
241 bb *Builder
242 want string
243 }{
244 {
245 bb: NewSetAttributeClaim(br, "attr1", "val1"),
246 want: `{"camliVersion": 1,
247 "attribute": "attr1",
248 "camliType": "claim",
249 "claimDate": "1970-01-01T00:02:03.000000456Z",
250 "claimType": "set-attribute",
251 "permaNode": "xxx-1234",
252 "value": "val1"
253}`,
254 },
255 {
256 bb: NewAddAttributeClaim(br, "tag", "funny"),
257 want: `{"camliVersion": 1,
258 "attribute": "tag",
259 "camliType": "claim",
260 "claimDate": "1970-01-01T00:02:03.000000456Z",
261 "claimType": "add-attribute",
262 "permaNode": "xxx-1234",
263 "value": "funny"
264}`,
265 },
266 {
267 bb: NewDelAttributeClaim(br, "attr1", "val1"),
268 want: `{"camliVersion": 1,
269 "attribute": "attr1",
270 "camliType": "claim",
271 "claimDate": "1970-01-01T00:02:03.000000456Z",
272 "claimType": "del-attribute",
273 "permaNode": "xxx-1234",
274 "value": "val1"
275}`,
276 },
277 {
278 bb: NewDelAttributeClaim(br, "attr2", ""),
279 want: `{"camliVersion": 1,
280 "attribute": "attr2",
281 "camliType": "claim",
282 "claimDate": "1970-01-01T00:02:03.000000456Z",
283 "claimType": "del-attribute",
284 "permaNode": "xxx-1234"
285}`,
286 },
287 {
288 bb: newClaim(&claimParam{
289 permanode: br,
290 claimType: SetAttributeClaim,
291 attribute: "foo",
292 value: "bar",
293 }, &claimParam{
294 permanode: br,

Callers

nothing calls this directly

Calls 7

MustParseFunction · 0.92
NewSetAttributeClaimFunction · 0.85
NewAddAttributeClaimFunction · 0.85
NewDelAttributeClaimFunction · 0.85
newClaimFunction · 0.85
SetClaimDateMethod · 0.80
JSONMethod · 0.45

Tested by

no test coverage detected