Skip to content

Panic when PersonalAccessToken is empty string #100

@cedws

Description

@cedws

Panics upon trying to use the client if the PersonalAccessToken field is left as its zero value.

func TestEmptyTokenPanics(t *testing.T) {
	client, err := scaleset.NewClientWithPersonalAccessToken(scaleset.NewClientWithPersonalAccessTokenConfig{
		GitHubConfigURL:     "https://github.com/cedws/test",
		PersonalAccessToken: "",
		SystemInfo:          scaleset.SystemInfo{},
	})
	assert.NoError(t, err)

	var panicked bool
	func() {
		defer func() {
			if r := recover(); r != nil {
				panicked = true
			}
		}()
		_, _ = client.GetRunnerScaleSet(t.Context(), 1, "test")
	}()

	assert.False(t, panicked, "panicked due to empty PersonalAccessToken")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions