Fail report showcase - bayashi/actually GitHub Wiki

Assert 1 object

Expect <nil>

playground

a.Got("").Nil(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox1163385091/prog_test.go:10
        	Function:    	Test()
        	Expected:    	<nil>
        	Actually got:	Type:string, ""
--- FAIL: Test (0.00s)
FAIL

Expect not <nil>

playground

a.Got(nil).NotNil(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox331591686/prog_test.go:10
        	Function:    	Test()
        	Fail reason: 	Expected other than <nil>, but got <nil>
        	Expected:    	Not <nil>
        	Actually got:	<nil>
--- FAIL: Test (0.00s)
FAIL

Expect True

playground

a.Got(1).True(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox543705390/prog_test.go:10
        	Function:    	Test()
        	Fail reason: 	Different type
        	Expected:    	Boolean type <true>
        	Actually got:	Type:int, 1
--- FAIL: Test (0.00s)
FAIL

same boolean type, but it's false

playground

a.Got(false).True(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox1884561809/prog_test.go:10
        	Function:    	Test()
        	Expected:    	Boolean type <true>
        	Actually got:	false
--- FAIL: Test (0.00s)
FAIL

Expect false

playground

a.Got(0).False(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox414188558/prog_test.go:10
        	Function:    	Test()
        	Fail reason: 	Different type
        	Expected:    	Boolean type <false>
        	Actually got:	Type:int, 0
--- FAIL: Test (0.00s)
FAIL

Assert 2 objects

Simple string

playground

a.Got("aiko").Expect("eiko").Same(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox2938945883/prog_test.go:10
        	Function:    	Test()
        	Fail reason: 	Not same value
        	Expected:    	Dump: "eiko"
        	Actually got:	Dump: "aiko"
        	Diff Details:	--- Expected
        	             	+++ Actually got
        	             	@@ -1 +1 @@
        	             	-eiko
        	             	+aiko
--- FAIL: Test (0.00s)
FAIL

Wrong type

playground

a.Got(int32(123)).Expect(float32(123)).Same(t)
=== RUN   Test
    prog_test.go:10: 
        	Trace:       	/tmp/sandbox4125056554/prog_test.go:10
        	Function:    	Test()
        	Fail reason: 	Different type
        	Expected:    	Type: float32, Dump: 123
        	Actually got:	Type: int32, Dump: 123
--- FAIL: Test (0.00s)
FAIL

Compare intricate strigns

func TestRoot3ChildrenGChildWithProp(t *testing.T) {
	expect := `
ā”Œ* root: tag
│   root description
ā”œā”€ā”¬+ Child: tag
│ │   Child description
│ └──$ G-Child: tag
│       G-Child description
ā”œā”€ā”€+ Child2: Tag
│     Child2 description
└──+ Child3: Tag
      Child3 description
`
	root := Node("root").Icon("*").Tag("tag").Description("root description")
	child := Node("Child").Icon("+").Tag("tag").Description("Child description")
	gchild := Node("G-Child").Icon("$").Tag("tag").Description("G-Child description")
	child2 := Node("Child2").Icon("+").Tag("tag").Description("Child2 description")
	child3 := Node("Child3").Icon("+").Tag("tag").Description("Child3 description")
	tree := root.Append(child.Append(gchild)).Append(child2).Append(child3)
	actually.Got(render(tree)).Expect(expect).X().Same(t)
}

Comparing by Same() with X() to show raw output.

render_test.go:111:
            Trace:          /home/bayashi/go/src/github.com/bayashi/go-proptree/render_test.go:111
            Function:       TestRoot3ChildrenGChildWithProp()
            Fail reason:    Not same value
            Expected:       Dump: "\nā”Œ* root: tag\n│   root description\nā”œā”€ā”¬+ Child: tag\n│ │   Child description\n│ └──$ G-Child: tag\n│       G-Child description\nā”œā”€ā”€+ Child2: Tag\n│     Child2 description\n└──+ Child3: Tag\n      Child3 description\n"
            Actually got:   Dump: "\nā”Œ* root: tag\n│   root description\nā”œā”€ā”¬+ Child: tag\n│ │   Child description\n│ └──$ G-Child: tag\n│       G-Child description\nā”œā”€ā”€+ Child2: tag\n│     Child2 description\n└──+ Child3: tag\n      Child3 description\n"
            Diff Details:   --- Expected
                            +++ Actually got
                            @@ -7,5 +7,5 @@
                             │       G-Child description
                            -ā”œā”€ā”€+ Child2: Tag
                            +ā”œā”€ā”€+ Child2: tag
                             │     Child2 description
                            -└──+ Child3: Tag
                            +└──+ Child3: tag
                                   Child3 description
            Expected Raw:   ---

                            ā”Œ* root: tag
                            │   root description
                            ā”œā”€ā”¬+ Child: tag
                            │ │   Child description
                            │ └──$ G-Child: tag
                            │       G-Child description
                            ā”œā”€ā”€+ Child2: Tag
                            │     Child2 description
                            └──+ Child3: Tag
                                  Child3 description

                            ---
            Got Raw:        ---

                            ā”Œ* root: tag
                            │   root description
                            ā”œā”€ā”¬+ Child: tag
                            │ │   Child description
                            │ └──$ G-Child: tag
                            │       G-Child description
                            ā”œā”€ā”€+ Child2: tag
                            │     Child2 description
                            └──+ Child3: tag
                                  Child3 description

                            ---
āš ļø **GitHub.com Fallback** āš ļø