Skip to content

Commit

Permalink
Merge pull request #71 from zaibon/project-types
Browse files Browse the repository at this point in the history
fix: update type of some field of Project struct to match response from deps.dev API
  • Loading branch information
edoardottt authored May 17, 2024
2 parents bd3a91f + ea85e26 commit 47f5f63
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
17 changes: 8 additions & 9 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ release:
*CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.*
footer: |
If you encounter a problem, just open an [issue](https://github.com/edoardottt/depsdev/issues)
If you encounter a problem, just open an [issue](https://github.com/edoardottt/depsdev/issues)
before:
hooks:
Expand All @@ -24,18 +24,17 @@ builds:
- arm64
ignore:
- goos: darwin
goarch: '386'
goarch: "386"
- goos: windows
goarch: 'arm'
goarch: "arm"
- goos: windows
goarch: 'arm64'
binary: '{{ .ProjectName }}'
main: ./cmd/depsdev/
goarch: "arm64"
binary: "{{ .ProjectName }}"
main: ./main.go

archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}'
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}'

checksum:
algorithm: sha256

14 changes: 7 additions & 7 deletions pkg/depsdev/definitions/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import "time"

type Project struct {
ProjectKey ProjectKey `json:"projectKey,omitempty"`
OpenIssuesCount string `json:"openIssuesCount,omitempty"`
StarsCount string `json:"starsCount,omitempty"`
ForksCount string `json:"forksCount,omitempty"`
OpenIssuesCount int `json:"openIssuesCount,omitempty"`
StarsCount int `json:"starsCount,omitempty"`
ForksCount int `json:"forksCount,omitempty"`
License string `json:"license,omitempty"`
Description string `json:"description,omitempty"`
Homepage string `json:"homepage,omitempty"`
Expand Down Expand Up @@ -50,7 +50,7 @@ type Documentation struct {
type Checks struct {
Name string `json:"name,omitempty"`
Documentation Documentation `json:"documentation,omitempty"`
Score string `json:"score,omitempty"`
Score float64 `json:"score,omitempty"`
Reason string `json:"reason,omitempty"`
Details []string `json:"details,omitempty"`
}
Expand All @@ -65,9 +65,9 @@ type Scorecard struct {
}

type OssFuzz struct {
LineCount string `json:"lineCount,omitempty"`
LineCoverCount string `json:"lineCoverCount,omitempty"`
LineCoverPercent string `json:"lineCoverPercent,omitempty"`
LineCount int `json:"lineCount,omitempty"`
LineCoverCount int `json:"lineCoverCount,omitempty"`
LineCoverPercent float64 `json:"lineCoverPercent,omitempty"`
Date time.Time `json:"date,omitempty"`
ConfigURL string `json:"configUrl,omitempty"`
}
12 changes: 12 additions & 0 deletions pkg/depsdev/v3/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@ import (

def "github.com/edoardottt/depsdev/pkg/depsdev/definitions"
"github.com/edoardottt/depsdev/pkg/depsdev/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var (
api = depsdev.NewV3API()
)

func TestGetProject(t *testing.T) {
t.Run("GetInfo npm defangjs", func(t *testing.T) {
got, err := api.GetProject("github.com/edoardottt/defangjs")
require.Nil(t, err)

// no checking of the actual value because they can change over time
// we just ensure the call to the API and unmarshaling of the response works properly
assert.NotEmpty(t, got)
})
}

func TestGetInfo(t *testing.T) {
result := `{
"packageKey": {
Expand Down

0 comments on commit 47f5f63

Please sign in to comment.