logo

go-deblob

remove binary blobs from a directory
commit: 07da04865f8e91ca962be74ba72fc83bd92519ec
parent: 4a9a227390d1568131d59b5571baa22e40101466
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 12 Dec 2019 01:52:28 +0100

Init tests

Diffstat:

MMakefile4++++
Ago-deblob_test.go27+++++++++++++++++++++++++++
Atest/fixtures/empty0
Atest/fixtures/hello0
Atest/fixtures/hello.112++++++++++++
Atest/fixtures/hello.ar0
Atest/fixtures/hello.c6++++++
7 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -12,6 +12,10 @@ all: go-build go-build: go build +.PHONY: test +test: + go test + .PHONY: install install: mkdir -p $(DESTDIR)$(BINDIR) diff --git a/go-deblob_test.go b/go-deblob_test.go @@ -0,0 +1,27 @@ +// This file is part of https://hacktivis.me/git/go-deblob +// Copyright © 2019 Haelwenn (lanodan) Monnier <contact+go-deblob-notice@hacktivis.me> +// SPDX-License-Identifier: BSD-3-Clause +package main + +import "testing" + +func TestIsBlob(t *testing.T) { + tests := []struct { + path string + expect bool + }{ + {"test/fixtures/hello.1", false}, + {"test/fixtures/hello.c", false}, + {"test/fixtures/hello", true}, + // {"test/fixtures/hello.o", true}, + {"test/fixtures/hello.ar", true}, + {"test/fixtures/empty", false}, + } + + for _, test := range tests { + got := isBlob(test.path) + if got != test.expect { + t.Errorf("isBlob(%s) was incorrect, got: %v, expects: %v.", test.path, got, test.expect) + } + } +} diff --git a/test/fixtures/empty b/test/fixtures/empty diff --git a/test/fixtures/hello b/test/fixtures/hello Binary files differ. diff --git a/test/fixtures/hello.1 b/test/fixtures/hello.1 @@ -0,0 +1,12 @@ +.Dd 2019-12-12 +.Dt hello 1 +.Os +.Sh NAME +.Nm hello +.Nd greets +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION +Greats the user with a message. +.Sh EXIT STATUS +.Ex -std diff --git a/test/fixtures/hello.ar b/test/fixtures/hello.ar Binary files differ. diff --git a/test/fixtures/hello.c b/test/fixtures/hello.c @@ -0,0 +1,5 @@ +#include <stdio.h> /* printf() */ + +int main(void) { + return printf("Hello World!\n"); +}+ \ No newline at end of file