Update blorg test - make it actually fail when public changes
This commit is contained in:
parent
d7ef673644
commit
c536adf6e9
3 changed files with 26 additions and 1 deletions
|
@ -1,6 +1,12 @@
|
|||
package blorg
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBlorg(t *testing.T) {
|
||||
config, err := ReadConfig("testdata/blorg.org")
|
||||
|
@ -8,7 +14,23 @@ func TestBlorg(t *testing.T) {
|
|||
t.Errorf("Could not read config: %s", err)
|
||||
return
|
||||
}
|
||||
commitedHashBs, err := ioutil.ReadFile("testdata/public.md5")
|
||||
if err != nil {
|
||||
t.Errorf("Could not read hash bytes: %s", err)
|
||||
return
|
||||
}
|
||||
if err := config.Render(); err != nil {
|
||||
t.Errorf("Could not render: %s", err)
|
||||
return
|
||||
}
|
||||
renderedHashBs, err := exec.Command("bash", "-c", fmt.Sprintf("find %s -type f | sort -u | xargs cat | md5sum", config.PublicDir)).Output()
|
||||
if err != nil {
|
||||
t.Errorf("Could not hash PublicDir: %s", err)
|
||||
return
|
||||
}
|
||||
rendered, committed := strings.TrimSpace(string(renderedHashBs)), strings.TrimSpace(string(commitedHashBs))
|
||||
if rendered != committed {
|
||||
t.Errorf("PublicDir hashes do not match: '%s' -> '%s'", committed, rendered)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue