| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package test
- import (
- "testing"
- "git.sxidc.com/go-framework/baize/framework/core/api"
- )
- func TestFormUrlInstruction(t *testing.T) {
- instruction := &api.PermUrlInstruction{
- Group: "group",
- Name: "name",
- Description: "description",
- NeedCheckExpire: true,
- SensitiveWordScene: 1,
- IsPrivilege: true,
- }
- formed := api.FormUrlInstruction(instruction)
- excepted := `${perm:"group:group;name:name;description:description;needCheckExpire;sensitiveWordScene:1;"}$`
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- instruction = &api.PermUrlInstruction{
- Group: "group",
- Name: "name",
- NeedCheckExpire: true,
- SensitiveWordScene: 1,
- }
- formed = api.FormUrlInstruction(instruction)
- excepted = `${perm:"group:group;name:name;needCheckExpire;sensitiveWordScene:1;"}$`
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- instruction = &api.PermUrlInstruction{
- Group: "group",
- Name: "name",
- SensitiveWordScene: 1,
- }
- formed = api.FormUrlInstruction(instruction)
- excepted = `${perm:"group:group;name:name;sensitiveWordScene:1;"}$`
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- instruction = &api.PermUrlInstruction{
- Group: "group",
- Name: "name",
- Description: "description",
- NeedCheckExpire: true,
- }
- formed = api.FormUrlInstruction(instruction)
- excepted = `${perm:"group:group;name:name;description:description;needCheckExpire;"}$`
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- instruction = &api.PermUrlInstruction{
- Group: "group",
- Name: "name",
- Description: "description",
- }
- formed = api.FormUrlInstruction(instruction)
- excepted = `${perm:"group:group;name:name;description:description;"}$`
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- instruction = &api.PermUrlInstruction{
- Group: "group",
- Name: "name",
- }
- formed = api.FormUrlInstruction(instruction)
- excepted = `${perm:"group:group;name:name;"}$`
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- formed = api.FormUrlInstruction(nil)
- excepted = ``
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- formed = api.FormUrlInstruction()
- excepted = ``
- if formed != excepted {
- t.Fatalf("生成错误 excepted: %s actual: %s\n", excepted, formed)
- }
- }
|