Skip to content

Commit

Permalink
Add With Existing Sess Test
Browse files Browse the repository at this point in the history
  • Loading branch information
tung.tq committed Feb 15, 2023
1 parent 2773141 commit bbf9adf
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions plain_memcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,30 @@ func TestPlainMemcache__Finish_Do_Flush(t *testing.T) {
Data: data,
}, getResp)
}

func TestPlainMemcache__With_Existing_Session(t *testing.T) {
client, err := memcache.New("localhost:11211", 1)
if err != nil {
panic(err)
}
t.Cleanup(func() {
_ = client.Close()
})

err = client.Pipeline().FlushAll()()
if err != nil {
panic(err)
}

cache := NewPlainMemcache(client,
WithPlainMemcacheLeaseDuration(7),
WithPlainMemcacheSessionProvider(NewSessionProvider()),
)

provider := NewSessionProvider()
sess := provider.New()

pipe := cache.Pipeline(context.Background(), WithPipelineExistingSession(sess))

assert.Same(t, sess.GetLower(), pipe.LowerSession())
}

0 comments on commit bbf9adf

Please sign in to comment.