Skip to content

Commit

Permalink
feat: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Nov 13, 2023
1 parent 1b77ec1 commit 4e5a17b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/topics/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// nolint: funlen
func TestTopic_GetType(t *testing.T) {
func TestTopicManager(t *testing.T) {
t.Parallel()

tests := []struct {
Expand Down
35 changes: 35 additions & 0 deletions internal/topics/topic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package topics_test

import (
"testing"
"text/template"

"github.com/snapp-incubator/soteria/internal/topics"
"github.com/snapp-incubator/soteria/pkg/acl"
"github.com/stretchr/testify/require"
)

func TestTopic(t *testing.T) {
require := require.New(t)

topic := topics.Topic{
Type: topics.CabEvent,
Template: "^{{.iss}}-event-$",
Accesses: map[string]acl.AccessType{
topics.DriverIss: acl.Sub,
topics.PassengerIss: acl.Sub,
},
}

temp := topics.Template{
Type: topic.Type,
Template: template.Must(template.New("").Parse(topic.Template)),
Accesses: topic.Accesses,
}

s := temp.Parse(map[string]string{
"iss": "passenger",
})

require.Equal("^passenger-event-$", s)
}

0 comments on commit 4e5a17b

Please sign in to comment.