コード例 #1
0
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")
		testdep.CheckEnv(t)
		t.Fatalf("PostGreSQL not available locally for testing: %v", err)
	}
	tfn(t, makeIndex)
}
コード例 #2
0
ファイル: mongoindex_test.go プロジェクト: splade/camlistore
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.")
		testdep.CheckEnv(t)
		t.Fatalf("Mongo not available locally for testing: %v", err)
	}
	tfn(t, initMongoIndex)
}
コード例 #3
0
ファイル: mysql_test.go プロジェクト: splade/camlistore
func (mysqlTester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) {
	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'")
		testdep.CheckEnv(t)
		t.Fatalf("MySQL not available locally for testing: %v", err)
	}
	tfn(t, makeIndex)
}
コード例 #4
0
// Reads google storage config and creates a Client.  Exits on error.
func doConfig(t *testing.T) (gsa *Client, bucket string) {
	if _, err := os.Stat("gstestconfig.json"); os.IsNotExist(err) {
		testdep.CheckEnv(t)
		t.Fatalf("Missing config file: %v", err)
	}
	cf, err := jsonconfig.ReadFile("testconfig.json")
	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(&oauth.Transport{
		&oauth.Config{
			ClientId:     auth.RequiredString("client_id"),
			ClientSecret: auth.RequiredString("client_secret"),
			Scope:        "https://www.googleapis.com/auth/devstorage.read_write",
			AuthURL:      "https://accounts.google.com/o/oauth2/auth",
			TokenURL:     "https://accounts.google.com/o/oauth2/token",
			RedirectURL:  "urn:ietf:wg:oauth:2.0:oob",
		},
		&oauth.Token{
			AccessToken:  "",
			RefreshToken: auth.RequiredString("refresh_token"),
		},
		nil,
	})

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