@@ -19,6 +19,18 @@ import (
1919 "github.com/imfing/diffs-cli/internal/appconfig"
2020)
2121
22+ func TestMain (m * testing.M ) {
23+ for k , v := range map [string ]string {
24+ "GIT_AUTHOR_NAME" : "Test" ,
25+ "GIT_AUTHOR_EMAIL" : "test@example.com" ,
26+ "GIT_COMMITTER_NAME" : "Test" ,
27+ "GIT_COMMITTER_EMAIL" : "test@example.com" ,
28+ } {
29+ _ = os .Setenv (k , v )
30+ }
31+ os .Exit (m .Run ())
32+ }
33+
2234func TestConfigIncludesCurrentBranch (t * testing.T ) {
2335 dir := t .TempDir ()
2436 git (t , dir , "init" )
@@ -131,8 +143,6 @@ func TestGitDiffNoIndexUsesDevNullHeader(t *testing.T) {
131143func TestLocalDiffIncludesStagedAndUnstagedTrackedChanges (t * testing.T ) {
132144 dir := t .TempDir ()
133145 git (t , dir , "init" )
134- git (t , dir , "config" , "user.email" , "test@example.com" )
135- git (t , dir , "config" , "user.name" , "Test" )
136146 writeFile (t , filepath .Join (dir , "tracked.txt" ), "one\n " )
137147 git (t , dir , "add" , "tracked.txt" )
138148 git (t , dir , "commit" , "-m" , "init" )
@@ -154,8 +164,6 @@ func TestLocalDiffIncludesStagedAndUnstagedTrackedChanges(t *testing.T) {
154164func TestEventsStreamOnLocalFileChange (t * testing.T ) {
155165 dir := t .TempDir ()
156166 git (t , dir , "init" )
157- git (t , dir , "config" , "user.email" , "test@example.com" )
158- git (t , dir , "config" , "user.name" , "Test" )
159167 writeFile (t , filepath .Join (dir , "tracked.txt" ), "one\n " )
160168 git (t , dir , "add" , "tracked.txt" )
161169 git (t , dir , "commit" , "-m" , "init" )
@@ -203,8 +211,6 @@ func TestEventsStreamOnLocalFileChange(t *testing.T) {
203211func TestOnChangeRunsOnLocalFileChange (t * testing.T ) {
204212 dir := t .TempDir ()
205213 git (t , dir , "init" )
206- git (t , dir , "config" , "user.email" , "test@example.com" )
207- git (t , dir , "config" , "user.name" , "Test" )
208214 writeFile (t , filepath .Join (dir , "tracked.txt" ), "one\n " )
209215 git (t , dir , "add" , "tracked.txt" )
210216 git (t , dir , "commit" , "-m" , "init" )
@@ -242,8 +248,6 @@ func TestOnChangeRunsOnLocalFileChange(t *testing.T) {
242248func TestOnChangeIgnoresGitCleanBuildOutput (t * testing.T ) {
243249 dir := t .TempDir ()
244250 git (t , dir , "init" )
245- git (t , dir , "config" , "user.email" , "test@example.com" )
246- git (t , dir , "config" , "user.name" , "Test" )
247251 writeFile (t , filepath .Join (dir , ".gitignore" ), "web/dist/\n " )
248252 git (t , dir , "add" , ".gitignore" )
249253 git (t , dir , "commit" , "-m" , "init" )
@@ -281,8 +285,6 @@ func TestOnChangeIgnoresGitCleanBuildOutput(t *testing.T) {
281285func TestEventsStreamIgnoresGitCleanBuildOutput (t * testing.T ) {
282286 dir := t .TempDir ()
283287 git (t , dir , "init" )
284- git (t , dir , "config" , "user.email" , "test@example.com" )
285- git (t , dir , "config" , "user.name" , "Test" )
286288 writeFile (t , filepath .Join (dir , ".gitignore" ), "web/dist/\n " )
287289 git (t , dir , "add" , ".gitignore" )
288290 git (t , dir , "commit" , "-m" , "init" )
@@ -330,8 +332,6 @@ func TestEventsStreamIgnoresGitCleanBuildOutput(t *testing.T) {
330332func TestWatcherDisabledDoesNotObserveLocalChanges (t * testing.T ) {
331333 dir := t .TempDir ()
332334 git (t , dir , "init" )
333- git (t , dir , "config" , "user.email" , "test@example.com" )
334- git (t , dir , "config" , "user.name" , "Test" )
335335 writeFile (t , filepath .Join (dir , "tracked.txt" ), "one\n " )
336336 git (t , dir , "add" , "tracked.txt" )
337337 git (t , dir , "commit" , "-m" , "init" )
@@ -361,8 +361,6 @@ func TestWatcherDisabledDoesNotObserveLocalChanges(t *testing.T) {
361361func TestGitStatusReturnsChangedPaths (t * testing.T ) {
362362 dir := t .TempDir ()
363363 git (t , dir , "init" )
364- git (t , dir , "config" , "user.email" , "test@example.com" )
365- git (t , dir , "config" , "user.name" , "Test" )
366364 writeFile (t , filepath .Join (dir , ".gitignore" ), "web/dist/\n " )
367365 writeFile (t , filepath .Join (dir , "tracked.txt" ), "one\n " )
368366 git (t , dir , "add" , ".gitignore" , "tracked.txt" )
@@ -396,8 +394,6 @@ func TestGitStatusReturnsChangedPaths(t *testing.T) {
396394func TestGitStatusActions (t * testing.T ) {
397395 dir := t .TempDir ()
398396 git (t , dir , "init" )
399- git (t , dir , "config" , "user.email" , "test@example.com" )
400- git (t , dir , "config" , "user.name" , "Test" )
401397 writeFile (t , filepath .Join (dir , "tracked.txt" ), "one\n " )
402398 git (t , dir , "add" , "tracked.txt" )
403399 git (t , dir , "commit" , "-m" , "init" )
@@ -429,8 +425,6 @@ func TestGitStatusActions(t *testing.T) {
429425func TestGitStatusUsesNewPathForRenames (t * testing.T ) {
430426 dir := t .TempDir ()
431427 git (t , dir , "init" )
432- git (t , dir , "config" , "user.email" , "test@example.com" )
433- git (t , dir , "config" , "user.name" , "Test" )
434428 writeFile (t , filepath .Join (dir , "old.txt" ), "one\n " )
435429 git (t , dir , "add" , "old.txt" )
436430 git (t , dir , "commit" , "-m" , "init" )
0 commit comments