Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Unit tests OSSFuzz client #3301

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions clients/ossfuzz/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package ossfuzz

import (
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -180,3 +182,175 @@ func setupServer(t *testing.T) string {
t.Cleanup(server.Close)
return server.URL
}

func TestAllClientMethods(t *testing.T) {
naveensrinivasan marked this conversation as resolved.
Show resolved Hide resolved
c := CreateOSSFuzzClient("testURL")

// Test InitRepo
{
err := c.InitRepo(nil, "", 0)
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("InitRepo: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test IsArchived
{
_, err := c.IsArchived()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("IsArchived: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test LocalPath
{
_, err := c.LocalPath()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("LocalPath: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListFiles
{
_, err := c.ListFiles(nil)
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListFiles: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test GetFileContent
{
_, err := c.GetFileContent("")
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("GetFileContent: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test GetBranch
{
_, err := c.GetBranch("")
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("GetBranch: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test GetDefaultBranch
{
_, err := c.GetDefaultBranch()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("GetDefaultBranch: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test GetOrgRepoClient
{
_, err := c.GetOrgRepoClient(context.Background())
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("GetOrgRepoClient: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test GetDefaultBranchName
{
_, err := c.GetDefaultBranchName()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("GetDefaultBranchName: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListCommits
{
_, err := c.ListCommits()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListCommits: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListIssues
{
_, err := c.ListIssues()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListIssues: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListReleases
{
_, err := c.ListReleases()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListReleases: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListContributors
{
_, err := c.ListContributors()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListContributors: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListSuccessfulWorkflowRuns
{
_, err := c.ListSuccessfulWorkflowRuns("")
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListSuccessfulWorkflowRuns: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListCheckRunsForRef
{
_, err := c.ListCheckRunsForRef("")
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListCheckRunsForRef: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListStatuses
{
_, err := c.ListStatuses("")
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListStatuses: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListWebhooks
{
_, err := c.ListWebhooks()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListWebhooks: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test SearchCommits
{
_, err := c.SearchCommits(clients.SearchCommitsOptions{})
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("SearchCommits: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test Close
{
err := c.Close()
if err != nil {
t.Errorf("Close: Expected no error, but got %v", err)
}
}

// Test ListProgrammingLanguages
{
_, err := c.ListProgrammingLanguages()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListProgrammingLanguages: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}

// Test ListLicenses
{
_, err := c.ListLicenses()
if !errors.Is(err, clients.ErrUnsupportedFeature) {
t.Errorf("ListLicenses: Expected %v, but got %v", clients.ErrUnsupportedFeature, err)
}
}
}