github.com/maheshbr/terraform@v0.3.1-0.20141020033300-deec7194a3ea/config/module/detect_bitbucket_test.go (about)

     1  package module
     2  
     3  import (
     4  	"net/http"
     5  	"testing"
     6  )
     7  
     8  const testBBUrl = "https://bitbucket.org/hashicorp/tf-test-git"
     9  
    10  func TestBitBucketDetector(t *testing.T) {
    11  	t.Parallel()
    12  
    13  	if _, err := http.Get(testBBUrl); err != nil {
    14  		t.Log("internet may not be working, skipping BB tests")
    15  		t.Skip()
    16  	}
    17  
    18  	cases := []struct {
    19  		Input  string
    20  		Output string
    21  	}{
    22  		// HTTP
    23  		{
    24  			"bitbucket.org/hashicorp/tf-test-git",
    25  			"git::https://bitbucket.org/hashicorp/tf-test-git.git",
    26  		},
    27  		{
    28  			"bitbucket.org/hashicorp/tf-test-git.git",
    29  			"git::https://bitbucket.org/hashicorp/tf-test-git.git",
    30  		},
    31  		{
    32  			"bitbucket.org/hashicorp/tf-test-hg",
    33  			"hg::https://bitbucket.org/hashicorp/tf-test-hg",
    34  		},
    35  	}
    36  
    37  	pwd := "/pwd"
    38  	f := new(BitBucketDetector)
    39  	for i, tc := range cases {
    40  		output, ok, err := f.Detect(tc.Input, pwd)
    41  		if err != nil {
    42  			t.Fatalf("err: %s", err)
    43  		}
    44  		if !ok {
    45  			t.Fatal("not ok")
    46  		}
    47  
    48  		if output != tc.Output {
    49  			t.Fatalf("%d: bad: %#v", i, output)
    50  		}
    51  	}
    52  }