Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goldenfile

Go test helper to verify output against golden files

Example

===
simple
===
var integer a;
---
(Root
  (VarDecl
    (Reference)
    (Declarators
      (Declarator
        (Name "a")))))

===
with assignment
===
var integer a := 5;
---
(Root
  (VarDecl
    (Reference)
    (Declarators
      (Declarator
        (Name "a")
        (Literal "5")))))

Testing

tests, err := goldenfile.Parse(fh)
if err != nil {
	t.Fatalf("goldenfile.Parse(%s): %s", file, err.Error())
}

if *goldenfile.Update {
	updateTests(t, tests)
}

for _, test := range tests {
	t.Run(test.Name, func (t *testing.T) {
		if myFunc(test.Text) != test.Want {
			log.Errorf("myFunc() failed")
		}
	})
}

About

Go test helper to verify output against golden files

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages