コード例 #1
0
// Reads google storage config and creates a Client.  Exits on error.
func doConfig(t *testing.T) (gsa *Client, bucket string) {
	gsConfigPath := filepath.Join(osutil.CamliConfigDir(), "gstestconfig.json")

	if _, err := os.Stat(gsConfigPath); os.IsNotExist(err) {
		test.DependencyErrorOrSkip(t)
		t.Fatalf("Missing config file: %v", err)
	}
	cf, err := jsonconfig.ReadFile(gsConfigPath)
	if err != nil {
		t.Fatalf("Failed to read config: %v", err)
	}

	var config jsonconfig.Obj
	config = cf.RequiredObject("gsconf")
	if err := cf.Validate(); err != nil {
		t.Fatalf("Invalid config: %v", err)
	}

	auth := config.RequiredObject("auth")
	bucket = config.RequiredString("bucket")
	if err := config.Validate(); err != nil {
		t.Fatalf("Invalid config: %v", err)
	}

	gsa = NewClient(MakeOauthTransport(auth.RequiredString("client_id"),
		auth.RequiredString("client_secret"),
		auth.RequiredString("refresh_token")))

	if err := auth.Validate(); err != nil {
		t.Fatalf("Invalid config: %v", err)
	}
	return
}
コード例 #2
0
ファイル: fs_test.go プロジェクト: camlistore/camlistore
func condSkip(t *testing.T) {
	errmu.Lock()
	defer errmu.Unlock()
	if !(runtime.GOOS == "darwin" || runtime.GOOS == "linux") {
		t.Skipf("Skipping test on OS %q", runtime.GOOS)
	}
	if runtime.GOOS == "darwin" {
		// TODO: simplify if/when bazil drops 2.x support.
		_, err := os.Stat(fuse.OSXFUSELocationV3.Mount)
		if err == nil {
			osxFuseMarker = "cammount@osxfuse"
			return
		}
		if !os.IsNotExist(err) {
			t.Fatal(err)
		}
		_, err = os.Stat(fuse.OSXFUSELocationV2.Mount)
		if err == nil {
			osxFuseMarker = "mount_osxfusefs@"
			// TODO(mpl): add a similar check/warning to pkg/fs or cammount.
			t.Log("OSXFUSE version 2.x detected. Please consider upgrading to v 3.x.")
			return
		}
		if !os.IsNotExist(err) {
			t.Fatal(err)
		}
		test.DependencyErrorOrSkip(t)
	}
}
コード例 #3
0
ファイル: postgres_test.go プロジェクト: rayleyva/camlistore
func skipOrFailIfNoPostgreSQL(t *testing.T) {
	once.Do(checkDB)
	if !dbAvailable {
		err := errors.New("Not running; start a postgres daemon on the standard port (5432) with password 'postgres' for postgres user")
		test.DependencyErrorOrSkip(t)
		t.Fatalf("PostGreSQL not available locally for testing: %v", err)
	}
}
コード例 #4
0
func skipOrFailIfNoMongo(t *testing.T) {
	once.Do(checkMongoUp)
	if mongoNotAvailable {
		err := errors.New("Not running; start a mongoDB daemon on the standard port (27017). The \"keys\" collection in the \"camlitest\" database will be used.")
		test.DependencyErrorOrSkip(t)
		t.Fatalf("Mongo not available locally for testing: %v", err)
	}
}
コード例 #5
0
ファイル: postgres_test.go プロジェクト: newobject/camlistore
func (postgresTester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) {
	once.Do(checkDB)
	if !dbAvailable {
		err := errors.New("Not running; start a postgres daemon on the standard port (5432) with password 'postgres' for postgres user")
		test.DependencyErrorOrSkip(t)
		t.Fatalf("PostGreSQL not available locally for testing: %v", err)
	}
	tfn(t, makeIndex)
}
コード例 #6
0
func (mongoTester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) {
	once.Do(checkMongoUp)
	if mongoNotAvailable {
		err := errors.New("Not running; start a mongoDB daemon on the standard port (27017). The \"keys\" collection in the \"camlitest\" database will be used.")
		test.DependencyErrorOrSkip(t)
		t.Fatalf("Mongo not available locally for testing: %v", err)
	}
	tfn(t, initMongoIndex)
}
コード例 #7
0
ファイル: mysql_test.go プロジェクト: ndarilek/camlistore
func skipOrFailIfNoMySQL(t *testing.T) {
	once.Do(checkDB)
	if !dbAvailable {
		// TODO(bradfitz): accept somehow other passwords than
		// 'root', and/or try localhost unix socket
		// connections rather than using TCP localhost?
		err := errors.New("Not running; start a MySQL daemon on the standard port (3306) with root password 'root'")
		test.DependencyErrorOrSkip(t)
		t.Fatalf("MySQL not available locally for testing: %v", err)
	}
}
コード例 #8
0
ファイル: fs_test.go プロジェクト: camarox53/coreos-baremetal
func condSkip(t *testing.T) {
	errmu.Lock()
	defer errmu.Unlock()
	if lasterr != nil {
		t.Skipf("Skipping test; some other test already failed.")
	}
	if !(runtime.GOOS == "darwin" || runtime.GOOS == "linux") {
		t.Skipf("Skipping test on OS %q", runtime.GOOS)
	}
	if runtime.GOOS == "darwin" {
		_, err := os.Stat("/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs")
		if os.IsNotExist(err) {
			test.DependencyErrorOrSkip(t)
		} else if err != nil {
			t.Fatal(err)
		}
	}
}