MCPcopy
hub / github.com/kashav/fsql / TestTransform_Format

Function TestTransform_Format

transform/format_test.go:9–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestTransform_Format(t *testing.T) {
10 type Expected struct {
11 val interface{}
12 err error
13 }
14
15 type Case struct {
16 params *FormatParams
17 expected Expected
18 }
19
20 // TODO: Add tests for the time and hash attribute.
21 cases := []Case{
22 {
23 params: &FormatParams{
24 Attribute: "size",
25 Path: "path",
26 Info: nil,
27 Value: int64(300),
28 Name: "format",
29 Args: []string{"kb"},
30 },
31 expected: Expected{
32 val: fmt.Sprintf("%fkb", float64(300)/(1<<10)),
33 err: nil,
34 },
35 },
36 {
37 params: &FormatParams{
38 Attribute: "size",
39 Path: "path",
40 Info: nil,
41 Value: int64(300),
42 Name: "format",
43 Args: []string{"kilobytes"},
44 },
45 expected: Expected{
46 val: nil,
47 err: &ErrUnsupportedFormat{"kilobytes", "size"},
48 },
49 },
50 {
51 params: &FormatParams{
52 Attribute: "name",
53 Path: "path",
54 Info: nil,
55 Value: "VALUE",
56 Name: "format",
57 Args: []string{"lower"},
58 },
59 expected: Expected{val: "value", err: nil},
60 },
61 {
62 params: &FormatParams{
63 Attribute: "name",
64 Path: "path",
65 Info: nil,
66 Value: "value",

Callers

nothing calls this directly

Calls 1

FormatFunction · 0.85

Tested by

no test coverage detected