MCPcopy Index your code
hub / github.com/upper/db / TestOptionTypeJsonbStruct

Method TestOptionTypeJsonbStruct

adapter/postgresql/postgresql_test.go:754–790  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

752}
753
754func (s *AdapterTests) TestOptionTypeJsonbStruct() {
755 sess := s.Session()
756
757 optionTypes := sess.Collection("option_types")
758
759 err := optionTypes.Truncate()
760 s.NoError(err)
761
762 type OptionType struct {
763 ID int64 `db:"id,omitempty"`
764 Name string `db:"name"`
765 Tags StringArray `db:"tags"`
766 Settings Settings `db:"settings"`
767 }
768
769 item1 := &OptionType{
770 Name: "Hi",
771 Tags: []string{"aah", "ok"},
772 Settings: Settings{Name: "a", Num: 123},
773 }
774
775 record, err := optionTypes.Insert(item1)
776 s.NoError(err)
777
778 if pk, ok := record.ID().(int64); !ok || pk == 0 {
779 s.T().Errorf("Expecting an ID.")
780 }
781
782 var item1Chk OptionType
783 err = optionTypes.Find(record).One(&item1Chk)
784 s.NoError(err)
785
786 s.Equal(2, len(item1Chk.Tags))
787 s.Equal("aah", item1Chk.Tags[0])
788 s.Equal("a", item1Chk.Settings.Name)
789 s.Equal(int64(123), item1Chk.Settings.Num)
790}
791
792func (s *AdapterTests) TestSchemaCollection() {
793 sess := s.Session()

Callers

nothing calls this directly

Calls 8

SessionMethod · 0.65
CollectionMethod · 0.65
TruncateMethod · 0.65
InsertMethod · 0.65
IDMethod · 0.65
ErrorfMethod · 0.65
OneMethod · 0.65
FindMethod · 0.65

Tested by

no test coverage detected