Skip to content

Commit

Permalink
Merge pull request #679 from Permify/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
tolgaOzen committed Sep 17, 2023
2 parents 0c16457 + df8d3bf commit 3c58612
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<a href="https://img.shields.io/github/commit-activity/m/Permify/permify?style=for-the-badge" target="_blank"><img src="https://img.shields.io/github/commit-activity/m/Permify/permify?style=for-the-badge" alt="Permify Commit Activity" /></a>&nbsp;
<a href="https://img.shields.io/github/actions/workflow/status/Permify/permify/release.yml?style=for-the-badge" target="_blank"><img src="https://img.shields.io/github/actions/workflow/status/Permify/permify/release.yml?style=for-the-badge" alt="GitHub Workflow Status" /></a>&nbsp;
<a href="https://scrutinizer-ci.com/g/Permify/permify/?branch=master" target="_blank"><img src="https://img.shields.io/scrutinizer/quality/g/Permify/permify/master?style=for-the-badge" alt="Scrutinizer code quality (GitHub/Bitbucket)" /></a>&nbsp;
<a href='https://coveralls.io/github/Permify/permify?branch=master'><img alt="Coveralls" src="https://img.shields.io/coverallsCoverage/github/Permify/permify?style=for-the-badge"></a>
</p>

## What is Permify?
Expand Down
26 changes: 26 additions & 0 deletions pkg/attribute/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,31 @@ var _ = Describe("attribute", func() {
Expect(EntityAndCallOrAttributeToString(tt.entity, tt.attributeOrCall, tt.arguments...)).Should(Equal(tt.result))
}
})

It("EntityToString", func() {
tests := []struct {
entity *base.Entity
result string
}{
{
entity: &base.Entity{
Type: "organization",
Id: "1",
},
result: "organization:1",
},
{
entity: &base.Entity{
Type: "repository",
Id: "abc",
},
result: "repository:abc",
},
}

for _, tt := range tests {
Expect(EntityToString(tt.entity)).Should(Equal(tt.result))
}
})
})
})
31 changes: 31 additions & 0 deletions pkg/cache/ristretto/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ristretto

import (
"testing"
)

func TestMaxCostOption(t *testing.T) {
// Create a Ristretto instance with a default value.
r := &Ristretto{}

// Apply the MaxCost option.
MaxCost("100")(r)

// Check if the maxCost field is set correctly.
if r.maxCost != "100" {
t.Errorf("Expected maxCost to be 100, but got %v", r.maxCost)
}
}

func TestNumberOfCountersOption(t *testing.T) {
// Create a Ristretto instance with a default value.
r := &Ristretto{}

// Apply the NumberOfCounters option.
NumberOfCounters(50)(r)

// Check if the numCounters field is set correctly.
if r.numCounters != 50 {
t.Errorf("Expected numCounters to be 50, but got %v", r.numCounters)
}
}

0 comments on commit 3c58612

Please sign in to comment.