forked from harness/harness
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ed9f8f
commit b1cbe65
Showing
5 changed files
with
31 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,9 @@ | ||
package session | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/drone/drone/model" | ||
"github.com/franela/goblin" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func TestSetPerm(t *testing.T) { | ||
g := goblin.Goblin(t) | ||
g.Describe("SetPerm", func() { | ||
g.BeforeEach(func() { | ||
os.Unsetenv("PUBLIC_MODE") | ||
}) | ||
g.It("Should set pull to false (private repo, user not logged in)", func() { | ||
c := gin.Context{} | ||
c.Set("repo", &model.Repo{ | ||
IsPrivate: true, | ||
}) | ||
SetPerm()(&c) | ||
v, ok := c.Get("perm") | ||
g.Assert(ok).IsTrue("perm was not set") | ||
p, ok := v.(*model.Perm) | ||
g.Assert(ok).IsTrue("perm was the wrong type") | ||
g.Assert(p.Pull).IsFalse("pull should be false") | ||
}) | ||
g.It("Should set pull to true (private repo, user not logged in, public mode)", func() { | ||
os.Setenv("PUBLIC_MODE", "true") | ||
c := gin.Context{} | ||
c.Set("repo", &model.Repo{ | ||
IsPrivate: true, | ||
}) | ||
SetPerm()(&c) | ||
v, ok := c.Get("perm") | ||
g.Assert(ok).IsTrue("perm was not set") | ||
p, ok := v.(*model.Perm) | ||
g.Assert(ok).IsTrue("perm was the wrong type") | ||
g.Assert(p.Pull).IsTrue("pull should be true") | ||
}) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters