github.com/drone/runner-go@v1.12.0/clone/environ_test.go (about)

     1  // Copyright 2019 Drone.IO Inc. All rights reserved.
     2  // Use of this source code is governed by the Polyform License
     3  // that can be found in the LICENSE file.
     4  
     5  package clone
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/google/go-cmp/cmp"
    11  )
    12  
    13  func TestEnvironDefault(t *testing.T) {
    14  	c := Config{}
    15  	a := Environ(c)
    16  	b := map[string]string{
    17  		"GIT_AUTHOR_NAME":     "drone",
    18  		"GIT_AUTHOR_EMAIL":    "noreply@drone",
    19  		"GIT_COMMITTER_NAME":  "drone",
    20  		"GIT_COMMITTER_EMAIL": "noreply@drone",
    21  		"GIT_TERMINAL_PROMPT": "0",
    22  	}
    23  	if diff := cmp.Diff(a, b); diff != "" {
    24  		t.Fail()
    25  		t.Log(diff)
    26  	}
    27  }
    28  
    29  func TestEnviron(t *testing.T) {
    30  	c := Config{
    31  		User: User{
    32  			Name:  "The Octocat",
    33  			Email: "octocat@github.com",
    34  		},
    35  		Trace:      true,
    36  		SkipVerify: true,
    37  	}
    38  	a := Environ(c)
    39  	b := map[string]string{
    40  		"GIT_AUTHOR_NAME":     "The Octocat",
    41  		"GIT_AUTHOR_EMAIL":    "octocat@github.com",
    42  		"GIT_COMMITTER_NAME":  "The Octocat",
    43  		"GIT_COMMITTER_EMAIL": "octocat@github.com",
    44  		"GIT_TERMINAL_PROMPT": "0",
    45  		"GIT_TRACE":           "true",
    46  		"GIT_SSL_NO_VERIFY":   "true",
    47  	}
    48  	if diff := cmp.Diff(a, b); diff != "" {
    49  		t.Fail()
    50  		t.Log(diff)
    51  	}
    52  }