Skip to content

Commit

Permalink
style: lint fix (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park authored Nov 29, 2023
1 parent 87c3ae1 commit a1012ed
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions pkg/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ func TestLoader_LoadOne(t *testing.T) {
Scheme: s,
Database: memdb.New(faker.Word()),
})

tb := symbol.NewTable()
defer func() { _ = tb.Close() }()

ld := New(Config{
Scheme: s,
Storage: st,
Table: tb,
})

kind := faker.Word()

spec1 := &scheme.SpecMeta{
ID: ulid.Make(),
Kind: kind,
Expand All @@ -51,66 +51,66 @@ func TestLoader_LoadOne(t *testing.T) {
},
},
}

codec := scheme.CodecFunc(func(spec scheme.Spec) (node.Node, error) {
return node.NewOneToOneNode(node.OneToOneNodeConfig{ID: spec.GetID()}), nil
})

s.AddKnownType(kind, &scheme.SpecMeta{})
s.AddCodec(kind, codec)

st.InsertOne(context.Background(), spec1)
st.InsertOne(context.Background(), spec2)

r, err := ld.LoadOne(context.Background(), spec2.GetID())
assert.NoError(t, err)
assert.NotNil(t, r)

_, ok := tb.LookupByID(spec1.GetID())
assert.True(t, ok)

_, ok = tb.LookupByID(spec2.GetID())
assert.True(t, ok)

})

t.Run("reload same ID", func(t *testing.T) {
s := scheme.New()
st, _ := storage.New(context.Background(), storage.Config{
Scheme: s,
Database: memdb.New(faker.Word()),
})

tb := symbol.NewTable()
defer func() { _ = tb.Close() }()

ld := New(Config{
Scheme: s,
Storage: st,
Table: tb,
})

kind := faker.Word()

spec := &scheme.SpecMeta{
ID: ulid.Make(),
Kind: kind,
Namespace: scheme.NamespaceDefault,
}

codec := scheme.CodecFunc(func(spec scheme.Spec) (node.Node, error) {
return node.NewOneToOneNode(node.OneToOneNodeConfig{ID: spec.GetID()}), nil
})

s.AddKnownType(kind, &scheme.SpecMeta{})
s.AddCodec(kind, codec)

st.InsertOne(context.Background(), spec)

r1, err := ld.LoadOne(context.Background(), spec.GetID())
assert.NoError(t, err)
assert.NotNil(t, r1)

r2, err := ld.LoadOne(context.Background(), spec.GetID())
assert.NoError(t, err)
assert.NotNil(t, r2)
Expand All @@ -124,43 +124,43 @@ func TestLoader_LoadOne(t *testing.T) {
Scheme: s,
Database: memdb.New(faker.Word()),
})

tb := symbol.NewTable()
defer func() { _ = tb.Close() }()

ld := New(Config{
Scheme: s,
Storage: st,
Table: tb,
})

kind := faker.Word()

spec := &scheme.SpecMeta{
ID: ulid.Make(),
Kind: kind,
Namespace: scheme.NamespaceDefault,
}

codec := scheme.CodecFunc(func(spec scheme.Spec) (node.Node, error) {
return node.NewOneToOneNode(node.OneToOneNodeConfig{ID: spec.GetID()}), nil
})

s.AddKnownType(kind, &scheme.SpecMeta{})
s.AddCodec(kind, codec)

st.InsertOne(context.Background(), spec)

r1, err := ld.LoadOne(context.Background(), spec.GetID())
assert.NoError(t, err)
assert.NotNil(t, r1)

st.DeleteOne(context.Background(), storage.Where[ulid.ULID](scheme.KeyID).EQ(spec.GetID()))

r2, err := ld.LoadOne(context.Background(), spec.GetID())
assert.NoError(t, err)
assert.Nil(t, r2)

_, ok := tb.LookupByID(spec.GetID())
assert.False(t, ok)
})
Expand Down

0 comments on commit a1012ed

Please sign in to comment.