Skip to content

Commit

Permalink
Run go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
troyanov committed May 18, 2020
1 parent d951292 commit c36cbae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,18 @@ func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error {
// AddPolicies adds policy rules to the storage.
func (a *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error {
var lines []*CasbinRule
for _,rule := range rules{
for _, rule := range rules {
line := savePolicyLine(ptype, rule)
lines = append(lines, line)
}

err := a.db.RunInTransaction(func(tx *pg.Tx) error {
_, err := tx.Model(&lines).
OnConflict("DO NOTHING").
Insert()
OnConflict("DO NOTHING").
Insert()
return err
})

return err
}

Expand All @@ -261,17 +261,17 @@ func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error {
// RemovePolicies removes policy rules from the storage.
func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) error {
var lines []*CasbinRule
for _,rule := range rules{
for _, rule := range rules {
line := savePolicyLine(ptype, rule)
lines = append(lines, line)
}

err := a.db.RunInTransaction(func(tx *pg.Tx) error {
_, err := tx.Model(&lines).
Delete()
Delete()
return err
})

return err
}

Expand Down
22 changes: 11 additions & 11 deletions adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ func (s *AdapterTestSuite) TestAutoSave() {
// The policy has a new rule: {"alice", "data1", "write"}.
s.assertPolicy(
[][]string{
{"alice", "data1", "read"},
{"bob", "data2", "write"},
{"data2_admin", "data2", "read"},
{"data2_admin", "data2", "write"},
{"alice", "data1", "write"},
{"bob", "data2", "read"},
{"alice", "data2", "write"},
{"alice", "data2", "read"},
{"bob", "data1", "write"},
{"bob", "data1", "read"},
},
{"alice", "data1", "read"},
{"bob", "data2", "write"},
{"data2_admin", "data2", "read"},
{"data2_admin", "data2", "write"},
{"alice", "data1", "write"},
{"bob", "data2", "read"},
{"alice", "data2", "write"},
{"alice", "data2", "read"},
{"bob", "data1", "write"},
{"bob", "data1", "read"},
},
s.e.GetPolicy(),
)

Expand Down

0 comments on commit c36cbae

Please sign in to comment.