snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
176
server/tests/system/queues_test.go
Normal file
176
server/tests/system/queues_test.go
Normal file
@@ -0,0 +1,176 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/id"
|
||||
mtypes "github.com/cortezaproject/corteza/server/pkg/messagebus/types"
|
||||
"github.com/cortezaproject/corteza/server/store"
|
||||
"github.com/cortezaproject/corteza/server/system/service"
|
||||
"github.com/cortezaproject/corteza/server/system/types"
|
||||
"github.com/cortezaproject/corteza/server/tests/helpers"
|
||||
jsonpath "github.com/steinfletcher/apitest-jsonpath"
|
||||
)
|
||||
|
||||
func (h helper) clearMessagebusQueues() {
|
||||
h.noError(store.TruncateQueues(context.Background(), service.DefaultStore))
|
||||
}
|
||||
|
||||
func (h helper) repoMakeMessagebusQueue(consumer ...string) *types.Queue {
|
||||
res := &types.Queue{
|
||||
ID: id.Next(),
|
||||
Queue: rs(),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
if len(consumer) == 0 {
|
||||
res.Consumer = string(mtypes.ConsumerCorteza)
|
||||
} else {
|
||||
res.Consumer = consumer[0]
|
||||
}
|
||||
|
||||
h.a.NoError(store.CreateQueue(context.Background(), service.DefaultStore, res))
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func (h helper) lookupByID(id uint64) *types.Queue {
|
||||
res, err := store.LookupQueueByID(context.Background(), service.DefaultStore, id)
|
||||
h.noError(err)
|
||||
return res
|
||||
}
|
||||
|
||||
func (h helper) lookupByQueue(queue string) *types.Queue {
|
||||
res, err := store.LookupQueueByQueue(context.Background(), service.DefaultStore, queue)
|
||||
h.noError(err)
|
||||
return res
|
||||
}
|
||||
|
||||
func TestQueueList(t *testing.T) {
|
||||
h := newHelper(t)
|
||||
h.clearMessagebusQueues()
|
||||
|
||||
h.repoMakeMessagebusQueue()
|
||||
h.repoMakeMessagebusQueue()
|
||||
|
||||
helpers.AllowMe(h, types.ComponentRbacResource(), "queues.search")
|
||||
helpers.AllowMe(h, types.QueueRbacResource(0), "read")
|
||||
|
||||
h.apiInit().
|
||||
Get("/queues/").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
Assert(jsonpath.Len(`$.response.set`, 2)).
|
||||
End()
|
||||
}
|
||||
|
||||
func TestQueueRead(t *testing.T) {
|
||||
h := newHelper(t)
|
||||
h.clearMessagebusQueues()
|
||||
|
||||
res := h.repoMakeMessagebusQueue()
|
||||
|
||||
helpers.AllowMe(h, types.ComponentRbacResource(), "queues.search")
|
||||
helpers.AllowMe(h, types.QueueRbacResource(0), "read")
|
||||
|
||||
h.apiInit().
|
||||
Get(fmt.Sprintf("/queues/%d", res.ID)).
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
}
|
||||
|
||||
func TestQueueCreate(t *testing.T) {
|
||||
h := newHelper(t)
|
||||
h.clearMessagebusQueues()
|
||||
|
||||
helpers.AllowMe(h, types.ComponentRbacResource(), "queue.create")
|
||||
|
||||
consumer := string(mtypes.ConsumerStore)
|
||||
queue := rs()
|
||||
|
||||
h.apiInit().
|
||||
Post("/queues").
|
||||
FormData("consumer", consumer).
|
||||
FormData("queue", queue).
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
res := h.lookupByQueue(queue)
|
||||
h.a.NotNil(res)
|
||||
h.a.Equal(consumer, res.Consumer)
|
||||
}
|
||||
|
||||
func TestQueueUpdate(t *testing.T) {
|
||||
h := newHelper(t)
|
||||
h.clearMessagebusQueues()
|
||||
|
||||
consumer := string(mtypes.ConsumerRedis)
|
||||
res := h.repoMakeMessagebusQueue()
|
||||
res.Consumer = consumer
|
||||
|
||||
helpers.AllowMe(h, types.QueueRbacResource(0), "update")
|
||||
|
||||
h.apiInit().
|
||||
Put(fmt.Sprintf("/queues/%d", res.ID)).
|
||||
Header("Accept", "application/json").
|
||||
JSON(helpers.JSON(res)).
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
res = h.lookupByID(res.ID)
|
||||
h.a.NotNil(res)
|
||||
h.a.Equal(consumer, res.Consumer)
|
||||
}
|
||||
|
||||
func TestQueueDelete(t *testing.T) {
|
||||
h := newHelper(t)
|
||||
h.clearMessagebusQueues()
|
||||
|
||||
res := h.repoMakeMessagebusQueue()
|
||||
|
||||
helpers.AllowMe(h, types.QueueRbacResource(0), "delete")
|
||||
|
||||
h.apiInit().
|
||||
Delete(fmt.Sprintf("/queues/%d", res.ID)).
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
res = h.lookupByID(res.ID)
|
||||
h.a.NotNil(res)
|
||||
h.a.NotNil(res.DeletedAt)
|
||||
}
|
||||
|
||||
func TestQueueUnDelete(t *testing.T) {
|
||||
h := newHelper(t)
|
||||
h.clearMessagebusQueues()
|
||||
|
||||
res := h.repoMakeMessagebusQueue()
|
||||
|
||||
helpers.AllowMe(h, types.QueueRbacResource(0), "delete")
|
||||
|
||||
h.apiInit().
|
||||
Post(fmt.Sprintf("/queues/%d/undelete", res.ID)).
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
res = h.lookupByID(res.ID)
|
||||
h.a.NotNil(res)
|
||||
h.a.Nil(res.DeletedAt)
|
||||
}
|
||||
Reference in New Issue
Block a user