Skip to content

Commit

Permalink
Tested group tags inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Mar 21, 2024
1 parent b756a53 commit 11df301
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,54 @@ func TestServerTags(t *testing.T) {

require.Equal(t, s.tags, []string{"my-server-tag"})
})

t.Run("inherit tags from group, replace", func(t *testing.T) {
s := NewServer().
Tags("my-server-tag")

group := Group(s, "/api").
Tags("my-group-tag")

require.Equal(t, group.tags, []string{"my-group-tag"})

subGroup := Group(group, "/users").
Tags("my-sub-group-tag")

require.Equal(t, subGroup.tags, []string{"my-sub-group-tag"})
})

t.Run("inherit tags from group, add", func(t *testing.T) {
s := NewServer().
Tags("my-server-tag")

group := Group(s, "/api").
AddTags("my-group-tag")

require.Equal(t, group.tags, []string{"my-server-tag", "my-group-tag"})

subGroup := Group(group, "/users").
AddTags("my-sub-group-tag")

require.Equal(t, subGroup.tags, []string{"my-server-tag", "my-group-tag", "my-sub-group-tag"})
})

t.Run("inherit tags from group, remove", func(t *testing.T) {
s := NewServer().
Tags("my-server-tag")

group := Group(s, "/api").
AddTags("my-group-tag")

require.Equal(t, group.tags, []string{"my-server-tag", "my-group-tag"})

siblingGroup := Group(s, "/api2").
AddTags("my-sibling-group-tag")

require.Equal(t, siblingGroup.tags, []string{"my-server-tag", "my-sibling-group-tag"})

subGroup := Group(group, "/users").
RemoveTags("my-group-tag")

require.Equal(t, subGroup.tags, []string{"my-server-tag"})
})
}

0 comments on commit 11df301

Please sign in to comment.