ass test for metas set
This commit is contained in:
@@ -374,7 +374,7 @@ func TestService_Counts(t *testing.T) {
|
||||
}, res)
|
||||
}
|
||||
|
||||
func TestService_Metas(t *testing.T) {
|
||||
func TestService_GetMetas(t *testing.T) {
|
||||
defer os.Remove(testDb)
|
||||
// two comments for https://radio-t.com
|
||||
b := DataStore{Interface: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
||||
@@ -401,6 +401,30 @@ func TestService_Metas(t *testing.T) {
|
||||
assert.Equal(t, true, pm[0].ReadOnly)
|
||||
}
|
||||
|
||||
func TestService_SetMetas(t *testing.T) {
|
||||
defer os.Remove(testDb)
|
||||
// two comments for https://radio-t.com
|
||||
b := DataStore{Interface: prepStoreEngine(t), EditDuration: 100 * time.Millisecond,
|
||||
AdminStore: admin.NewStaticKeyStore("secret 123")}
|
||||
umetas := []UserMetaData{}
|
||||
pmetas := []PostMetaData{}
|
||||
err := b.SetMetas("radio-t", umetas, pmetas)
|
||||
assert.NoError(t, err, "empty metas")
|
||||
|
||||
um1 := UserMetaData{ID: "user1", Verified: true}
|
||||
um2 := UserMetaData{ID: "user2"}
|
||||
um2.Blocked.Status = true
|
||||
um2.Blocked.Until = time.Now().AddDate(0, 1, 1)
|
||||
|
||||
pmetas = []PostMetaData{{URL: "https://radio-t.com", ReadOnly: true}}
|
||||
err = b.SetMetas("radio-t", []UserMetaData{um1, um2}, pmetas)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.True(t, b.IsReadOnly(store.Locator{SiteID: "radio-t", URL: "https://radio-t.com"}))
|
||||
assert.True(t, b.IsVerified("radio-t", "user1"))
|
||||
assert.True(t, b.IsBlocked("radio-t", "user2"))
|
||||
}
|
||||
|
||||
// makes new boltdb, put two records
|
||||
func prepStoreEngine(t *testing.T) engine.Interface {
|
||||
os.Remove(testDb)
|
||||
|
||||
Reference in New Issue
Block a user