|
|
|
@@ -32,6 +32,7 @@ func TestService_CreateFromEmpty(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
ks := admin.NewStaticKeyStore("secret 123")
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: ks}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
|
User: store.User{IP: "192.168.1.1", ID: "user", Name: "name"},
|
|
|
|
@@ -56,6 +57,7 @@ func TestService_CreateSiteDisabled(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
ks := admin.NewStaticStore("secret 123", []string{"xxx"}, nil, "email")
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: ks}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
|
User: store.User{IP: "192.168.1.1", ID: "user", Name: "name"},
|
|
|
|
@@ -69,6 +71,7 @@ func TestService_CreateFromPartial(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
ks := admin.NewStaticKeyStore("secret 123")
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: ks}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
|
Timestamp: time.Date(2018, 3, 25, 16, 34, 33, 0, time.UTC),
|
|
|
|
@@ -97,6 +100,7 @@ func TestService_CreateFromPartialWithTitle(t *testing.T) {
|
|
|
|
|
ks := admin.NewStaticKeyStore("secret 123")
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: ks,
|
|
|
|
|
TitleExtractor: NewTitleExtractor(http.Client{Timeout: 5 * time.Second})}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
|
Timestamp: time.Date(2018, 3, 25, 16, 34, 33, 0, time.UTC),
|
|
|
|
@@ -147,6 +151,7 @@ func TestService_SetTitle(t *testing.T) {
|
|
|
|
|
ks := admin.NewStaticKeyStore("secret 123")
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: ks,
|
|
|
|
|
TitleExtractor: NewTitleExtractor(http.Client{Timeout: 5 * time.Second})}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
|
Timestamp: time.Date(2018, 3, 25, 16, 34, 33, 0, time.UTC),
|
|
|
|
@@ -172,6 +177,7 @@ func TestService_SetTitle(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "post1 blah 123", c.PostTitle)
|
|
|
|
|
|
|
|
|
|
b = DataStore{Engine: prepStoreEngine(t), AdminStore: ks}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
_, err = b.SetTitle(store.Locator{URL: tss.URL + "/post1", SiteID: "radio-t"}, id)
|
|
|
|
|
require.EqualError(t, err, "no title extractor")
|
|
|
|
|
}
|
|
|
|
@@ -179,6 +185,7 @@ func TestService_SetTitle(t *testing.T) {
|
|
|
|
|
func TestService_Vote(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"), MaxVotes: -1}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
@@ -281,6 +288,7 @@ func TestService_Vote(t *testing.T) {
|
|
|
|
|
func TestService_VoteLimit(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"), MaxVotes: 2}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
_, err := b.Vote(VoteReq{Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, CommentID: "id-1",
|
|
|
|
|
UserID: "user2", Val: true})
|
|
|
|
@@ -303,6 +311,7 @@ func TestService_VoteLimit(t *testing.T) {
|
|
|
|
|
func TestService_VotesDisabled(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"), MaxVotes: 0}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
_, err := b.Vote(VoteReq{Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, CommentID: "id-1",
|
|
|
|
|
UserID: "user2", Val: true})
|
|
|
|
@@ -312,6 +321,7 @@ func TestService_VotesDisabled(t *testing.T) {
|
|
|
|
|
func TestService_VoteAggressive(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"), MaxVotes: -1}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
@@ -376,6 +386,7 @@ func TestService_VoteConcurrent(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"), MaxVotes: -1}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
Text: "text",
|
|
|
|
@@ -410,6 +421,7 @@ func TestService_VotePositive(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"),
|
|
|
|
|
MaxVotes: -1, PositiveScore: true}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
_, err := b.Vote(VoteReq{Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, CommentID: "id-1",
|
|
|
|
|
UserID: "user2", Val: false})
|
|
|
|
@@ -421,6 +433,7 @@ func TestService_VotePositive(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
b = DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"),
|
|
|
|
|
MaxVotes: -1, PositiveScore: false}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
c, err := b.Vote(VoteReq{Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, CommentID: "id-1",
|
|
|
|
|
UserID: "user2", Val: false})
|
|
|
|
|
assert.NoError(t, err, "minimal score ignored")
|
|
|
|
@@ -431,6 +444,7 @@ func TestService_VotePositive(t *testing.T) {
|
|
|
|
|
func TestService_VoteControversy(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"), MaxVotes: -1}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
c, err := b.Vote(VoteReq{Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, CommentID: "id-2",
|
|
|
|
|
UserID: "user2", Val: false})
|
|
|
|
@@ -461,6 +475,7 @@ func TestService_VoteSameIP(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"),
|
|
|
|
|
MaxVotes: -1}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
b.RestrictSameIPVotes.Enabled = true
|
|
|
|
|
|
|
|
|
|
c, err := b.Vote(VoteReq{Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, CommentID: "id-2",
|
|
|
|
@@ -483,6 +498,7 @@ func TestService_VoteSameIPWithDuration(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123"),
|
|
|
|
|
MaxVotes: -1}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
b.RestrictSameIPVotes.Enabled = true
|
|
|
|
|
b.RestrictSameIPVotes.Duration = 50 * time.Millisecond
|
|
|
|
|
|
|
|
|
@@ -536,6 +552,7 @@ func TestService_Controversy(t *testing.T) {
|
|
|
|
|
func TestService_Pin(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Last("radio-t", 0, time.Time{}, store.User{})
|
|
|
|
|
t.Logf("%+v", res[0])
|
|
|
|
@@ -560,6 +577,7 @@ func TestService_Pin(t *testing.T) {
|
|
|
|
|
func TestService_EditComment(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Last("radio-t", 0, time.Time{}, store.User{})
|
|
|
|
|
t.Logf("%+v", res[0])
|
|
|
|
@@ -587,6 +605,7 @@ func TestService_EditComment(t *testing.T) {
|
|
|
|
|
func TestService_DeleteComment(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Last("radio-t", 0, time.Time{}, store.User{})
|
|
|
|
|
t.Logf("%+v", res[0])
|
|
|
|
@@ -607,6 +626,7 @@ func TestService_EditCommentDurationFailed(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Last("radio-t", 0, time.Time{}, store.User{})
|
|
|
|
|
t.Logf("%+v", res[0])
|
|
|
|
@@ -624,6 +644,7 @@ func TestService_EditCommentDurationFailed(t *testing.T) {
|
|
|
|
|
func TestService_EditCommentReplyFailed(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Last("radio-t", 0, time.Time{}, store.User{})
|
|
|
|
|
t.Logf("%+v", res[1])
|
|
|
|
@@ -676,6 +697,7 @@ func TestService_ValidateComment(t *testing.T) {
|
|
|
|
|
func TestService_Counts(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := prepStoreEngine(t) // two comments for https://radio-t.com
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for https://radio-t.com/2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -707,6 +729,7 @@ func TestService_GetMetas(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
um, pm, err := b.Metas("radio-t")
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@@ -752,6 +775,7 @@ func TestService_SetMetas(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
umetas := []UserMetaData{}
|
|
|
|
|
pmetas := []PostMetaData{}
|
|
|
|
|
err := b.SetMetas("radio-t", umetas, pmetas)
|
|
|
|
@@ -778,6 +802,7 @@ func TestService_UserDetailsOperations(t *testing.T) {
|
|
|
|
|
defer teardown(t)
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add single valid entry
|
|
|
|
|
result, err := b.SetUserEmail(store.Locator{SiteID: "radio-t"}, "u1", "test@example.com")
|
|
|
|
@@ -814,6 +839,7 @@ func TestService_IsAdmin(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", []string{"radio-t"}, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
assert.False(t, b.IsAdmin("radio-t", "user1"))
|
|
|
|
|
assert.True(t, b.IsAdmin("radio-t", "user2"))
|
|
|
|
@@ -827,6 +853,7 @@ func TestService_HasReplies(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", []string{"radio-t"}, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
ID: "id-1",
|
|
|
|
@@ -858,6 +885,7 @@ func TestService_UserReplies(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t),
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
c1 := store.Comment{
|
|
|
|
|
ID: "comment-id-1",
|
|
|
|
@@ -935,6 +963,7 @@ func TestService_Find(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Find(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, "time", store.User{})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@@ -967,6 +996,7 @@ func TestService_FindSince(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.FindSince(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, "time", store.User{}, time.Time{})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@@ -986,6 +1016,7 @@ func TestService_Info(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
info, err := b.Info(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, 0)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@@ -1007,6 +1038,7 @@ func TestService_Delete(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
res, err := b.Last("radio-t", 0, time.Time{}, store.User{})
|
|
|
|
|
assert.Equal(t, 2, len(res))
|
|
|
|
@@ -1026,6 +1058,7 @@ func TestService_DeleteUser(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for user2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1056,6 +1089,7 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for user2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1087,6 +1121,7 @@ func TestService_Count(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for user2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1118,6 +1153,7 @@ func TestService_UserComments(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for user2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1142,6 +1178,7 @@ func TestService_UserCount(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for user2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1171,6 +1208,7 @@ func TestService_DeleteAll(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com, no reply
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticStore("secret 123", nil, []string{"user2"}, "user@email.com")}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
// add one more for user2
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1202,6 +1240,7 @@ func TestService_submitImages(t *testing.T) {
|
|
|
|
|
// two comments for https://radio-t.com
|
|
|
|
|
b := DataStore{Engine: prepStoreEngine(t), EditDuration: 50 * time.Millisecond,
|
|
|
|
|
AdminStore: admin.NewStaticKeyStore("secret 123"), ImageService: imgSvc}
|
|
|
|
|
defer b.Close()
|
|
|
|
|
|
|
|
|
|
c := store.Comment{
|
|
|
|
|
ID: "id-22",
|
|
|
|
@@ -1257,6 +1296,7 @@ func Benchmark_ServiceCreate(b *testing.B) {
|
|
|
|
|
boltStore, err := engine.NewBoltDB(bolt.Options{}, engine.BoltSite{FileName: dbFile, SiteID: "radio-t"})
|
|
|
|
|
svc := DataStore{Engine: boltStore, EditDuration: 50 * time.Millisecond, AdminStore: admin.NewStaticKeyStore("secret 123")}
|
|
|
|
|
require.NoError(b, err)
|
|
|
|
|
defer svc.Close()
|
|
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
|
comment := store.Comment{
|
|
|
|
@@ -1277,7 +1317,6 @@ func prepStoreEngine(t *testing.T) engine.Interface {
|
|
|
|
|
st := time.Now()
|
|
|
|
|
boltStore, err := engine.NewBoltDB(bolt.Options{}, engine.BoltSite{FileName: testDb, SiteID: "radio-t"})
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
b := boltStore
|
|
|
|
|
|
|
|
|
|
comment := store.Comment{
|
|
|
|
|
ID: "id-1",
|
|
|
|
@@ -1286,7 +1325,7 @@ func prepStoreEngine(t *testing.T) engine.Interface {
|
|
|
|
|
Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"},
|
|
|
|
|
User: store.User{ID: "user1", Name: "user name"},
|
|
|
|
|
}
|
|
|
|
|
_, err = b.Create(comment)
|
|
|
|
|
_, err = boltStore.Create(comment)
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
comment = store.Comment{
|
|
|
|
@@ -1296,10 +1335,10 @@ func prepStoreEngine(t *testing.T) engine.Interface {
|
|
|
|
|
Locator: store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"},
|
|
|
|
|
User: store.User{ID: "user1", Name: "user name"},
|
|
|
|
|
}
|
|
|
|
|
_, err = b.Create(comment)
|
|
|
|
|
_, err = boltStore.Create(comment)
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
t.Logf("prepared store engine in %v", time.Since(st))
|
|
|
|
|
return b
|
|
|
|
|
return boltStore
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func teardown(_ *testing.T) {
|
|
|
|
|