Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcorbyeaglen committed Jan 21, 2018
1 parent 52338a4 commit f9d2bca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
30 changes: 15 additions & 15 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ func TestMyFirst(testing *testing.T) {
Given(testing, theSystemSetup).
When(somethingHappens).
Then(func(testing base.TestingT,
actual testdata.CapturedIO,
givens testdata.InterestingGivens,
) { // passed in testing should be used for assertions
actual testdata.CapturedIO,
givens testdata.InterestingGivens,
) { // passed in testing should be used for assertions

//we do some assertions here, commenting why
AssertThat(testing, actual["actual"], is.EqualTo("some output"))
})
//we do some assertions here, commenting why
AssertThat(testing, actual["actual"], is.EqualTo("some output"))
})
}

func somethingHappens(actual testdata.CapturedIO, expected testdata.InterestingGivens) {
Expand All @@ -40,9 +40,9 @@ func TestMyFirst_Ranged(testing *testing.T) {
}).
When(somethingHappensWithThe(test)).
Then(func(t base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
//do assertions
AssertThat(t, givens["actual"], has.Length(test.expected))
})
//do assertions
AssertThat(t, givens["actual"], has.Length(test.expected))
})
}
}

Expand All @@ -60,21 +60,21 @@ func TestMyFirst_Skipped(tst *testing.T) {
givens["actual"] = test.actual
}).
SkippingThisOneIf(func(someData ...interface{}) bool {
return test.actual == "fff"
}, "some data %s does not work yet", test.actual).
return test.actual == "fff"
}, "some data %s does not work yet", test.actual).
When(somethingHappensWithThe(test)).
Then(func(t base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
AssertThat(t, test.actual, is.EqualTo("a").Reason("we only want to assert if test actual is a not empty"))
})
AssertThat(t, test.actual, is.EqualTo("a").Reason("we only want to assert if test actual is a not empty"))
})
})
}
}

func TestWithoutGiven(t *testing.T) {
When(t, somethingHappens).
Then(func(testing base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
AssertThat(testing, actual["actual"], is.EqualTo("some output"))
})
AssertThat(testing, actual["actual"], is.EqualTo("some output"))
})
}

func somethingHappensWithThe(data struct {
Expand Down
2 changes: 1 addition & 1 deletion generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package gogiven
import (
"fmt"
"github.com/corbym/gogiven/generator"
"github.com/corbym/htmlspec"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/corbym/htmlspec"
)

// Generator is a global variable that holds the GoGivensOutputGenerator.
Expand Down
2 changes: 1 addition & 1 deletion given.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"regexp"
"runtime"
"strings"
"io/ioutil"
)

var globalTestContextMap = newSafeMap()
Expand Down
40 changes: 20 additions & 20 deletions given_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func TestGivenWhenSetsInterestingGiven(testing *testing.T) {
Given(testing, someDataSetup).
When(someAction).
Then(func(t base.TestingT,
actual testdata.CapturedIO,
givens testdata.InterestingGivens) {
//do assertions
AssertThat(t, actual["foo"], is.EqualTo("foob"))
})
actual testdata.CapturedIO,
givens testdata.InterestingGivens) {
//do assertions
AssertThat(t, actual["foo"], is.EqualTo("foob"))
})
}

func TestGivenWhenExercisingRanges(testing *testing.T) {
Expand All @@ -64,10 +64,10 @@ func TestGivenWhenExercisingRanges(testing *testing.T) {
return
}).
Then(func(t base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
//do assertions
testMetaData = append(testMetaData, t.(*base.TestMetaData))
AssertThat(t, test.actual, has.Length(test.expected))
})
//do assertions
testMetaData = append(testMetaData, t.(*base.TestMetaData))
AssertThat(t, test.actual, has.Length(test.expected))
})
}
AssertThat(testing, some[0].CapturedIO()["value"], is.EqualTo(""))
AssertThat(testing, some[0].CapturedIO()["expected"], is.EqualTo(0))
Expand All @@ -90,10 +90,10 @@ func TestInnerTestRangesOverValues(t *testing.T) {

Given(tInner, givenSome_Stuffs("a")).
When(func(capturedIO testdata.CapturedIO, givens testdata.InterestingGivens) {
givens["value"] = test.value
givens["expected"] = test.expected
capturedIO["actual"] = len(test.value)
}).Then(func(testingT base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
givens["value"] = test.value
givens["expected"] = test.expected
capturedIO["actual"] = len(test.value)
}).Then(func(testingT base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
AssertThat(testingT, actual["actual"], is.EqualTo(test.expected))
})
})
Expand All @@ -110,11 +110,11 @@ func TestGivenWhenStacksGivens(testing *testing.T) {
Given(testing, someDataSetup, andMoreDataSetup).
When(someAction).
Then(func(testing base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
//do assertions
AssertThat(testing, givens, has.AllKeys("1", "2", "blarg"))
AssertThat(testing, givens, is.ValueContaining("hi", 12, "foo"))
AssertThat(testing, actual, has.Key("foo"))
})
//do assertions
AssertThat(testing, givens, has.AllKeys("1", "2", "blarg"))
AssertThat(testing, givens, is.ValueContaining("hi", 12, "foo"))
AssertThat(testing, actual, has.Key("foo"))
})
}
func TestGivenWhenSkips(testing *testing.T) {
testing.Parallel()
Expand All @@ -123,8 +123,8 @@ func TestGivenWhenSkips(testing *testing.T) {
SkippingThisOne("some reason").
When(someAction).
Then(func(testing base.TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens) {
//do assertions
})
//do assertions
})
AssertThat(testing, t.Skipped(), is.EqualTo(true))
AssertThat(testing, t.TestOutput(), is.EqualTo("some reason"))
}
Expand Down

0 comments on commit f9d2bca

Please sign in to comment.