Example #1
0
func TestRemoveByIdFirst(t *testing.T) {
	evs := evsFixture()
	evs.removeInternalById("123")

	if !reflect.DeepEqual(*evs.vars, []travis.EnvironmentVariable{
		travis.EnvironmentVariable{Name: util.String("xyz"), ID: util.String("456")},
		travis.EnvironmentVariable{Name: util.String("abc"), ID: util.String("789")},
	}) {
		t.Fatal("failed removing by Id")
	}
}
Example #2
0
File: travis.go Project: rjz/hubbub
// Construct an instance of TravisService configured for the given facts
//
// Attempts to configure for either travis.org, or--failing that--for travis
// pro / travis.com.
func TravisServiceFactory(facts *hubbub.Facts) (*hubbub.Service, error) {

	ts := TravisService{}
	owner := facts.GetString("repo.owner")
	name := facts.GetString("repo.name")

	// try travis.com (travis pro)
	if facts.IsAvailable(PRO) && configureClient(&ts, travis.NewProClient(hubbub.String(facts.GetString(PRO))), owner, name) {
		svc := hubbub.Service(&ts)
		return &svc, nil
	}

	// try travis.org
	if facts.IsAvailable(ORG) && configureClient(&ts, travis.NewClient(hubbub.String(facts.GetString(ORG))), owner, name) {
		svc := hubbub.Service(&ts)
		return &svc, nil
	}

	return nil, errors.New("Failed to configure Travis client")
}
Example #3
0
File: github.go Project: rjz/hubbub
func parseHookParams(attrs *json.RawMessage) (*hookParams, error) {
	params := hookParams{}
	if err := json.Unmarshal([]byte(*attrs), &params); err != nil {
		return nil, err
	}

	if params.Name == nil {
		// default to webhook, users can override with service hooks if needed
		// https://developer.github.com/webhooks/#service-hooks
		params.Name = hubbub.String("web")
	}

	return &params, nil
}
Example #4
0
func evsFixture() EnvVarService {
	return EnvVarService{
		vars: &[]travis.EnvironmentVariable{
			travis.EnvironmentVariable{Name: util.String("xyz"), ID: util.String("123")},
			travis.EnvironmentVariable{Name: util.String("xyz"), ID: util.String("456")},
			travis.EnvironmentVariable{Name: util.String("abc"), ID: util.String("789")},
		},
	}
}