Skip to content

Commit

Permalink
add test for GetProject
Browse files Browse the repository at this point in the history
  • Loading branch information
zaibon committed May 16, 2024
1 parent 2a7aafe commit 23830df
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/depsdev/v3/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,40 @@ 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) {
result := `{
"projectKey": {
"id": "github.com/edoardottt/defangjs"
},
"openIssuesCount": 0,
"starsCount": 22,
"forksCount": 1,
"license": "GPL-3.0",
"description": "URL / IP / Email defanging with Javascript. Make IoC harmless.",
"homepage": "https://www.npmjs.com/package/defangjs"
}`
got, err := api.GetProject("github.com/edoardottt/defangjs")
require.Nil(t, err)

var d def.Project

if err := json.Unmarshal([]byte(result), &d); err != nil {
log.Fatal(err)
}

assert.Equal(t, d, got)
})
}

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

0 comments on commit 23830df

Please sign in to comment.