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

cleanup unused code #1325

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.test
.astro/
.Dockerfile.sql_cli
.DS_Store
.env
.idea/
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ test:
temp-astro:
cd $(shell mktemp -d) && ${PWD}/astro dev init

temp-astro-flow:
./astro flow init $(shell mktemp -d)

mock: mockery mock_airflow mock_houston mock_astro mock_pkg mock_astro_core mock_airflow_api

mock_houston:
Expand Down
18 changes: 0 additions & 18 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
"github.com/Masterminds/semver"
"github.com/golang-jwt/jwt/v4"
"github.com/pkg/errors"

// "Masterminds/semver" does not support the format of pre-release tags for SQL CLI, so we're using "hashicorp/go-version"
goVersion "github.com/hashicorp/go-version"
)

type CustomClaims struct {
Expand Down Expand Up @@ -103,21 +100,6 @@ func IsM1(myOS, myArch string) bool {
return false
}

func IsRequiredVersionMet(currentVersion, requiredVersion string) (bool, error) {
v1, err := goVersion.NewVersion(currentVersion)
if err != nil {
return false, err
}
constraints, err := goVersion.NewConstraint(requiredVersion)
if err != nil {
return false, err
}
if constraints.Check(v1) {
return true, nil
}
return false, nil
}

func ParseAPIToken(astroAPIToken string) (*CustomClaims, error) {
// Parse the token to peek at the custom claims
jwtParser := jwt.NewParser()
Expand Down
51 changes: 0 additions & 51 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -229,53 +228,3 @@ func TestIsM1(t *testing.T) {
assert.False(t, IsM1("windows", "amd64"))
})
}

var (
errMalformedCurrentVersion = errors.New("Malformed version: invalid current version") //nolint:stylecheck
errMalformedConstraint = errors.New("Malformed constraint: invalid constraint") //nolint:stylecheck
)

func TestIsRequiredVersionMet(t *testing.T) {
type args struct {
currentVersion string
requiredVersion string
}
type result struct {
valid bool
err error
}

tests := []struct {
name string
args args
want result
}{
{
name: "first true case",
args: args{"7.1.0", ">7.0.0, <8.0.0"},
want: result{true, nil},
},
{
name: "first false case",
args: args{"7.1.0", ">7.1.0"},
want: result{false, nil},
},
{
name: "first error case",
args: args{"invalid current version", ">7.0.0, <8.0.0"},
want: result{false, errMalformedCurrentVersion},
},
{
name: "second error case",
args: args{"7.1.0", "invalid constraint"},
want: result{false, errMalformedConstraint},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if versionMet, err := IsRequiredVersionMet(tt.args.currentVersion, tt.args.requiredVersion); versionMet != tt.want.valid || (err != nil && err.Error() != tt.want.err.Error()) {
t.Errorf("IsRequiredVersionMet() = %v, %v; want %v, %v", versionMet, err, tt.want.valid, tt.want.err)
}
})
}
}
1 change: 0 additions & 1 deletion src/astro-sql-cli
Submodule astro-sql-cli deleted from 0173a0