(t *testing.T)
| 676 | } |
| 677 | |
| 678 | func TestRecordCustomData(t *testing.T) { |
| 679 | t.Parallel() |
| 680 | |
| 681 | collection := core.NewAuthCollection("test") |
| 682 | collection.Fields.Add(&core.TextField{Name: "field1"}) |
| 683 | collection.Fields.Add(&core.TextField{Name: "field2"}) |
| 684 | |
| 685 | m := core.NewRecord(collection) |
| 686 | m.Id = "test_id" // direct id assignment |
| 687 | m.Set("email", "test@example.com") |
| 688 | m.Set("password", "123") // hidden fields should be also returned |
| 689 | m.Set("tokenKey", "789") |
| 690 | m.Set("field1", 123) |
| 691 | m.Set("field2", 456) |
| 692 | m.Set("unknown", 789) |
| 693 | |
| 694 | raw, err := json.Marshal(m.CustomData()) |
| 695 | if err != nil { |
| 696 | t.Fatal(err) |
| 697 | } |
| 698 | |
| 699 | expected := `{"unknown":789}` |
| 700 | |
| 701 | if v := string(raw); v != expected { |
| 702 | t.Fatalf("Expected\n%v\ngot\n%v", expected, v) |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | func TestRecordSetGet(t *testing.T) { |
| 707 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…