-
-
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.
new project for golang. Leveraging go:embed
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module civichacker/lovelanguage | ||
|
||
go 1.18 |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import ( | ||
"embed" | ||
) | ||
|
||
//go:embed schemas/*.json | ||
var schemas embed.FS |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func TestSchemaLoading(t *testing.T){ | ||
var tests = []struct { | ||
name string | ||
filename string | ||
}{ | ||
// the table itself | ||
{"use of force", "schemas/use-of-force.schema"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
content, err := schemas.ReadFile(fmt.Sprintf("%s.json", tt.filename)) | ||
result := json.Valid([]byte(content)) | ||
|
||
if err != nil { | ||
t.Errorf("loading schema failed: %s", err) | ||
} else if !result { | ||
t.Errorf("schema is not valid JSON") | ||
} | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"$id": "https://raw.githubusercontent.com/civichacker/love-language/master/schemas/use-of-force.schema.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "x-use-of-force", | ||
"description": "Most law enforcement agencies have policies that guide their use of force. These policies describe a escalating series of actions an officer may take to resolve a situation. This continuum generally has many levels, and officers are instructed to respond with a level of force appropriate to the situation at hand, acknowledging that the officer may move from one part of the continuum to another in a matter of seconds. https://nij.ojp.gov/topics/articles/use-force-continuum", | ||
"type": "object", | ||
"allOf": [ | ||
{ | ||
"$ref": "https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sros/relationship.json" | ||
}, | ||
{ | ||
"properties": { | ||
"x_civichacker_deadly_force": { | ||
"type": "string", | ||
"enum": [ | ||
"anticipatory", | ||
"premptive", | ||
"reactive" | ||
] | ||
}, | ||
"source_ref": { | ||
"type": "string", | ||
"pattern": "^(incident|identity)--" | ||
}, | ||
"target_ref": { | ||
"type": "string", | ||
"pattern": "^identity--" | ||
}, | ||
"x_civichacker_force_applied": { | ||
"type": "string", | ||
"description": "Indicates where on the Use of Force continuum force was used.", | ||
"enum": [ | ||
"presence", | ||
"verbalization", | ||
"empty-hand-control", | ||
"less-lethal-methods", | ||
"lethal-force" | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"if": { | ||
"properties": { | ||
"extensions": { | ||
"type": "object", | ||
"required": ["extension-definition--9c59fd79-4215-4ba2-920d-3e4f320e1e62"] | ||
} | ||
} | ||
}, | ||
"then": { | ||
"required": ["x_civichacker_use_of_force"] | ||
} | ||
}, | ||
{ | ||
"if": { | ||
"properties": { | ||
"x_civichacker_use_of_force": { | ||
"type": "string", | ||
"pattern": "^lethal-force$" | ||
} | ||
} | ||
}, | ||
"then": { | ||
"required": ["x_civichacker_deadly_force"] | ||
} | ||
} | ||
] | ||
} |