-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comment out test cases and check for error on reseller
- Loading branch information
Showing
3 changed files
with
109 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,91 @@ | ||
package pro | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"testing" | ||
// Todo | ||
// @Paul we might need to find way to use mock here rather calling actual api | ||
// Using actual api will be slow and also it will created redundant data in db | ||
// func TestClient(t *testing.T) { | ||
// log := golog.LoggerFor("pro-http-test") | ||
// client := NewClient("https://api.getiantem.org", &Opts{ | ||
// // Just use the default transport since otherwise test setup is difficult. | ||
// // This means it does not actually touch the proxying code, but that should | ||
// // be tested separately. | ||
// HttpClient: &http.Client{}, | ||
// UserConfig: func() common.UserConfig { | ||
// return common.NewUserConfig( | ||
// "Lantern", | ||
// "device123", // deviceID | ||
// 123, // userID | ||
// "token", // token | ||
// nil, | ||
// "en", // language | ||
// ) | ||
// }, | ||
// }) | ||
// res, e := client.Plans(context.Background()) | ||
// if !assert.NoError(t, e) { | ||
// return | ||
// } | ||
// log.Debugf("Got response: %v", res) | ||
// assert.NotNil(t, res) | ||
// } | ||
|
||
"github.com/getlantern/golog" | ||
"github.com/getlantern/lantern-client/internalsdk/common" | ||
"github.com/getlantern/lantern-client/internalsdk/protos" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
// func TestLinkValidate(t *testing.T) { | ||
// log := golog.LoggerFor("pro-http-test") | ||
// client := NewClient("https://api.getiantem.org", &Opts{ | ||
// // Just use the default transport since otherwise test setup is difficult. | ||
// // This means it does not actually touch the proxying code, but that should | ||
// // be tested separately. | ||
// HttpClient: &http.Client{}, | ||
// UserConfig: func() common.UserConfig { | ||
// return common.NewUserConfig( | ||
// "Lantern", | ||
// "device123", // deviceID | ||
// 123, // userID | ||
// "token", // token | ||
// nil, | ||
// "en", // language | ||
// ) | ||
// }, | ||
// }) | ||
// prepareRequestBody := &protos.ValidateRecoveryCodeRequest{ | ||
// Email: "[email protected]", | ||
// Code: "123456", | ||
// } | ||
// res, e := client.ValidateEmailRecoveryCode(context.Background(), prepareRequestBody) | ||
// if !assert.NoError(t, e) { | ||
// return | ||
// } | ||
// log.Debugf("Got response: %v", res) | ||
// assert.NotNil(t, res) | ||
// } | ||
|
||
func TestClient(t *testing.T) { | ||
log := golog.LoggerFor("pro-http-test") | ||
client := NewClient("https://api.getiantem.org", &Opts{ | ||
// Just use the default transport since otherwise test setup is difficult. | ||
// This means it does not actually touch the proxying code, but that should | ||
// be tested separately. | ||
HttpClient: &http.Client{}, | ||
UserConfig: func() common.UserConfig { | ||
return common.NewUserConfig( | ||
"Lantern", | ||
"device123", // deviceID | ||
123, // userID | ||
"token", // token | ||
nil, | ||
"en", // language | ||
) | ||
}, | ||
}) | ||
res, e := client.Plans(context.Background()) | ||
if !assert.NoError(t, e) { | ||
return | ||
} | ||
log.Debugf("Got response: %v", res) | ||
assert.NotNil(t, res) | ||
} | ||
|
||
func TestLinkValidate(t *testing.T) { | ||
log := golog.LoggerFor("pro-http-test") | ||
client := NewClient("https://api.getiantem.org", &Opts{ | ||
// Just use the default transport since otherwise test setup is difficult. | ||
// This means it does not actually touch the proxying code, but that should | ||
// be tested separately. | ||
HttpClient: &http.Client{}, | ||
UserConfig: func() common.UserConfig { | ||
return common.NewUserConfig( | ||
"Lantern", | ||
"device123", // deviceID | ||
123, // userID | ||
"token", // token | ||
nil, | ||
"en", // language | ||
) | ||
}, | ||
}) | ||
prepareRequestBody := &protos.ValidateRecoveryCodeRequest{ | ||
Email: "[email protected]", | ||
Code: "123456", | ||
} | ||
res, e := client.ValidateEmailRecoveryCode(context.Background(), prepareRequestBody) | ||
if !assert.NoError(t, e) { | ||
return | ||
} | ||
log.Debugf("Got response: %v", res) | ||
assert.NotNil(t, res) | ||
} | ||
|
||
func TestSignUp(t *testing.T) { | ||
log := golog.LoggerFor("pro-http-test") | ||
client := NewClient("https://api.getiantem.org", &Opts{ | ||
// Just use the default transport since otherwise test setup is difficult. | ||
// This means it does not actually touch the proxying code, but that should | ||
// be tested separately. | ||
HttpClient: &http.Client{}, | ||
UserConfig: func() common.UserConfig { | ||
return common.NewUserConfig( | ||
"Lantern", | ||
"device123", // deviceID | ||
123, // userID | ||
"token", // token | ||
nil, | ||
"en", // language | ||
) | ||
}, | ||
}) | ||
prepareRequestBody := &protos.SignupRequest{ | ||
Email: "[email protected]", | ||
Salt: []byte("salt"), | ||
Verifier: []byte("verifier"), | ||
} | ||
res, e := client.SignUp(context.Background(), prepareRequestBody) | ||
if !assert.NoError(t, e) { | ||
return | ||
} | ||
log.Debugf("Got response: %v", res) | ||
assert.NotNil(t, res) | ||
} | ||
// func TestSignUp(t *testing.T) { | ||
// log := golog.LoggerFor("pro-http-test") | ||
// client := NewClient("https://api.getiantem.org", &Opts{ | ||
// // Just use the default transport since otherwise test setup is difficult. | ||
// // This means it does not actually touch the proxying code, but that should | ||
// // be tested separately. | ||
// HttpClient: &http.Client{}, | ||
// UserConfig: func() common.UserConfig { | ||
// return common.NewUserConfig( | ||
// "Lantern", | ||
// "device123", // deviceID | ||
// 123, // userID | ||
// "token", // token | ||
// nil, | ||
// "en", // language | ||
// ) | ||
// }, | ||
// }) | ||
// prepareRequestBody := &protos.SignupRequest{ | ||
// Email: "[email protected]", | ||
// Salt: []byte("salt"), | ||
// Verifier: []byte("verifier"), | ||
// } | ||
// res, e := client.SignUp(context.Background(), prepareRequestBody) | ||
// if !assert.NoError(t, e) { | ||
// return | ||
// } | ||
// log.Debugf("Got response: %v", res) | ||
// assert.NotNil(t, res) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters