3
0
Files
corteza/internal/rules/resource_test.go
Tit Petric 876a304def upd(all):
- moved Access type from system to internal/rules,
- moved Resource from system to internal/rules,
- update imports for new type locations,
- add scope list container to inject permissions,
- update permissions API call to return default perms,
- update codegen for generated Rules types
2019-02-06 11:19:32 +01:00

34 lines
700 B
Go

package rules
import (
"fmt"
"testing"
"encoding/json"
"github.com/crusttech/crust/internal/test"
)
func TestResource(t *testing.T) {
var (
assert = test.Assert
)
r := Resource{123, "Test name", "team"}
assert(t, r.String() == "team:123", "Resource ID doesn't match, team:123 != '%s'", r.String())
b, _ := json.Marshal(r)
fmt.Println(string(b))
{
r := ResourceJSON{}
json.Unmarshal(b, &r)
assert(t, r.ResourceID == "team:123", "Decoded full-json resource ID doesn't match, team:123 != '%s'", r.ResourceID)
}
{
r := Resource{}
json.Unmarshal(b, &r)
assert(t, r.String() == "team:123", "Decoded full-json resource ID doesn't match, team:123 != '%s'", r.String())
}
}