package classes import ( "context" "testing" "git.golem15.com/golem15/summercms/modules/lighthouse" "gorm.io/gorm" ) func TestMaterialChannel(t *testing.T) { for _, id := range []uint{1, 5, 42, 1234567890} { ch := MaterialChannel(id) got, ok := MaterialChannelID(ch) if !ok || got != id { t.Errorf("MaterialChannelID(%q) = %d, %v, want %d, true", ch, got, ok, id) } } if got := MaterialChannel(5); got != "materials:5" { t.Errorf("MaterialChannel(5) = %q", got) } for _, ch := range []string{ "materials:5abc", "materials:05", "materials:0", "materials:5:x", "presence:materials:5", "materials:", "materials", "materials:-5", "materials: 5", "materials:99999999999999999999", "user:5", "", } { if id, ok := MaterialChannelID(ch); ok { t.Errorf("MaterialChannelID(%q) = %d, true, want a refusal", ch, id) } } } func TestMaterialRevisionNotifierNil(t *testing.T) { ctx := context.Background() var nilNotifier *MaterialRevisionNotifier nilNotifier.Revised(ctx, &gorm.DB{}, 5, 2) (&MaterialRevisionNotifier{}).Revised(ctx, &gorm.DB{}, 5, 2) (&MaterialRevisionNotifier{Realtime: &lighthouse.Service{}}).Revised(ctx, nil, 5, 2) }