本文整理汇总了Golang中github.com/jojopoper/horizon/test.LoadScenario函数的典型用法代码示例。如果您正苦于以下问题:Golang LoadScenario函数的具体用法?Golang LoadScenario怎么用?Golang LoadScenario使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadScenario函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPaymentActions
func TestPaymentActions(t *testing.T) {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Payment Actions:", t, func() {
Convey("GET /payments", func() {
w := rh.Get("/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 4)
})
Convey("GET /ledgers/:ledger_id/payments", func() {
w := rh.Get("/ledgers/1/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/ledgers/3/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
Convey("GET /accounts/:account_id/payments", func() {
w := rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
test.LoadScenario("pathed_payment")
w = rh.Get("/accounts/GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /transactions/:tx_id/payments", func() {
test.LoadScenario("pathed_payment")
w := rh.Get("/transactions/42450ffe3956b8618cffaae48665c252869440aeb41fd8bf4921929a61982630/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/transactions/95324dec7c94f8cc992522794b2a84a732cddcb5641992589cfe328884a4c132/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
})
}
示例2: TestOperationByIdQuery
func TestOperationByIdQuery(t *testing.T) {
test.LoadScenario("base")
Convey("OperationByIdQuery", t, func() {
var op OperationRecord
Convey("Existing record behavior", func() {
id := int64(8589938689)
q := OperationByIdQuery{
SqlQuery{history},
id,
}
err := Get(ctx, q, &op)
So(err, ShouldBeNil)
So(op.Id, ShouldEqual, id)
So(op.TransactionId, ShouldEqual, id-1)
})
Convey("Missing record behavior", func() {
id := int64(0)
q := OperationByIdQuery{
SqlQuery{history},
id,
}
err := Get(ctx, q, &op)
So(err, ShouldEqual, ErrNoResults)
})
})
}
示例3: TestAccountActions
func TestAccountActions(t *testing.T) {
Convey("Account Actions:", t, func() {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", func() {
w := rh.Get("/accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
var result AccountResource
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(result.Sequence, ShouldEqual, 3)
})
Convey("GET /accounts/100", func() {
w := rh.Get("/accounts/100", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 404)
})
Convey("GET /accounts", func() {
w := rh.Get("/accounts", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
w = rh.Get("/accounts?limit=1", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
})
}
示例4: TestLedgerBySequenceQuery
func TestLedgerBySequenceQuery(t *testing.T) {
Convey("LedgerBySequenceQuery", t, func() {
test.LoadScenario("base")
var record LedgerRecord
Convey("Existing record behavior", func() {
sequence := int32(2)
q := LedgerBySequenceQuery{
SqlQuery{history},
sequence,
}
err := Get(ctx, q, &record)
So(err, ShouldBeNil)
So(record.Sequence, ShouldEqual, sequence)
})
Convey("Missing record behavior", func() {
sequence := int32(-1)
query := LedgerBySequenceQuery{
SqlQuery{history},
sequence,
}
err := Get(ctx, query, &record)
So(err, ShouldEqual, ErrNoResults)
})
})
}
示例5: TestTradeActions
func TestTradeActions(t *testing.T) {
Convey("Trade Actions:", t, func() {
test.LoadScenario("trades")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /accounts/:account_id/trades", func() {
w := rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/trades", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
Convey("GET /order_book/trades", func() {
url := "/order_book/trades?" +
"selling_asset_type=credit_alphanum4&" +
"selling_asset_code=EUR&" +
"selling_asset_issuer=GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG&" +
"buying_asset_type=credit_alphanum4&" +
"buying_asset_code=USD&" +
"buying_asset_issuer=GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4"
w := rh.Get(url, test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
})
}
示例6: TestLedgerPageQuery
func TestLedgerPageQuery(t *testing.T) {
test.LoadScenario("base")
var records []LedgerRecord
Convey("LedgerPageQuery", t, func() {
pq, err := NewPageQuery("", "asc", 2)
So(err, ShouldBeNil)
q := LedgerPageQuery{SqlQuery{history}, pq}
err = Select(ctx, q, &records)
So(err, ShouldBeNil)
So(len(records), ShouldEqual, 2)
So(records, ShouldBeOrderedAscending, func(r interface{}) int64 {
return r.(LedgerRecord).Id
})
lastLedger := records[len(records)-1]
q.Cursor = lastLedger.PagingToken()
err = Select(ctx, q, &records)
So(err, ShouldBeNil)
t.Log(records)
So(len(records), ShouldEqual, 1)
})
}
示例7: TestHistoryAccountByAddressQuery
func TestHistoryAccountByAddressQuery(t *testing.T) {
test.LoadScenario("base")
Convey("AccountByAddress", t, func() {
var account HistoryAccountRecord
Convey("Existing record behavior", func() {
address := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"
q := HistoryAccountByAddressQuery{
SqlQuery{history},
address,
}
err := Get(ctx, q, &account)
So(err, ShouldBeNil)
So(account.Id, ShouldEqual, 0)
So(account.Address, ShouldEqual, address)
})
Convey("Missing record behavior", func() {
address := "not real"
q := HistoryAccountByAddressQuery{
SqlQuery{history},
address,
}
err := Get(ctx, q, &account)
So(err, ShouldEqual, ErrNoResults)
})
})
}
示例8: TestLedgerActions
func TestLedgerActions(t *testing.T) {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Ledger Actions:", t, func() {
Convey("GET /ledgers/1", func() {
w := rh.Get("/ledgers/1", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
var result LedgerResource
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(result.Sequence, ShouldEqual, 1)
})
Convey("GET /ledgers/100", func() {
w := rh.Get("/ledgers/100", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 404)
})
Convey("GET /ledgers", func() {
Convey("With Default Params", func() {
w := rh.Get("/ledgers", test.RequestHelperNoop)
var result map[string]interface{}
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(w.Code, ShouldEqual, 200)
embedded := result["_embedded"].(map[string]interface{})
records := embedded["records"].([]interface{})
So(len(records), ShouldEqual, 3)
})
Convey("With A Limit", func() {
w := rh.Get("/ledgers?limit=1", test.RequestHelperNoop)
var result map[string]interface{}
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(w.Code, ShouldEqual, 200)
embedded := result["_embedded"].(map[string]interface{})
records := embedded["records"].([]interface{})
So(len(records), ShouldEqual, 1)
})
})
})
}
示例9: TestAccountByAddressQuery
func TestAccountByAddressQuery(t *testing.T) {
test.LoadScenario("non_native_payment")
Convey("AccountByAddress", t, func() {
var account AccountRecord
notreal := "not_real"
withtl := "GBXGQJWVLWOYHFLVTKWV5FGHA3LNYY2JQKM7OAJAUEQFU6LPCSEFVXON"
notl := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"
q := AccountByAddressQuery{
Core: SqlQuery{core},
History: SqlQuery{history},
Address: withtl,
}
err := Get(ctx, q, &account)
So(err, ShouldBeNil)
So(account.Address, ShouldEqual, withtl)
So(account.Seqnum, ShouldEqual, 8589934593)
So(len(account.Trustlines), ShouldEqual, 1)
q.Address = notl
err = Get(ctx, q, &account)
So(err, ShouldBeNil)
So(len(account.Trustlines), ShouldEqual, 0)
q.Address = notreal
err = Get(ctx, q, &account)
So(err, ShouldEqual, ErrNoResults)
})
}
示例10: TestEffectActions
func TestEffectActions(t *testing.T) {
test.LoadScenario("base")
Convey("Effect Actions:", t, func() {
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /effects", func() {
w := rh.Get("/effects?limit=20", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 11)
})
Convey("GET /ledgers/:ledger_id/effects", func() {
w := rh.Get("/ledgers/1/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/ledgers/2/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 9)
w = rh.Get("/ledgers/3/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 2)
})
Convey("GET /accounts/:account_id/effects", func() {
w := rh.Get("/accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
w = rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 2)
w = rh.Get("/accounts/GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /transactions/:tx_id/effects", func() {
w := rh.Get("/transactions/c492d87c4642815dfb3c7dcce01af4effd162b031064098a0d786b6e0a00fd74/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /operations/:op_id/effects", func() {
w := rh.Get("/operations/8589938689/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
})
}
示例11: TestRootAction
func TestRootAction(t *testing.T) {
Convey("GET /", t, func() {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
w := rh.Get("/", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
})
}
示例12: TestLedgerStateQuery
func TestLedgerStateQuery(t *testing.T) {
test.LoadScenario("base")
Convey("LedgerStateQuery", t, func() {
var ls LedgerState
q := LedgerStateQuery{
SqlQuery{history},
SqlQuery{core},
}
err := Get(ctx, q, &ls)
So(err, ShouldBeNil)
So(ls.HorizonSequence, ShouldEqual, 3)
So(ls.StellarCoreSequence, ShouldEqual, 3)
})
}
示例13: TestOfferActions
func TestOfferActions(t *testing.T) {
test.LoadScenario("trades")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Offer Actions:", t, func() {
Convey("GET /accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/offers", func() {
w := rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/offers", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
})
}
示例14: TestLedgerState
func TestLedgerState(t *testing.T) {
test.LoadScenario("base")
horizon := OpenTestDatabase()
defer horizon.Close()
core := OpenStellarCoreTestDatabase()
defer core.Close()
Convey("db.UpdateLedgerState", t, func() {
So(horizonLedgerGauge.Value(), ShouldEqual, 0)
So(stellarCoreLedgerGauge.Value(), ShouldEqual, 0)
UpdateLedgerState(test.Context(), SqlQuery{horizon}, SqlQuery{core})
So(horizonLedgerGauge.Value(), ShouldEqual, 3)
So(stellarCoreLedgerGauge.Value(), ShouldEqual, 3)
})
}
示例15: TestCoreTrustlinesByAddressQuery
func TestCoreTrustlinesByAddressQuery(t *testing.T) {
test.LoadScenario("non_native_payment")
Convey("CoreTrustlinesByAddress", t, func() {
var tls []CoreTrustlineRecord
withtl := "GBXGQJWVLWOYHFLVTKWV5FGHA3LNYY2JQKM7OAJAUEQFU6LPCSEFVXON"
notl := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"
q := CoreTrustlinesByAddressQuery{
SqlQuery{core},
withtl,
}
err := Select(ctx, q, &tls)
So(err, ShouldBeNil)
So(len(tls), ShouldEqual, 1)
tl := tls[0]
So(tl.Accountid, ShouldEqual, withtl)
So(tl.Issuer, ShouldEqual, "GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4")
So(tl.Balance, ShouldEqual, 500000000)
So(tl.Tlimit, ShouldEqual, 9223372036854775807)
So(tl.Assetcode, ShouldEqual, "USD")
q = CoreTrustlinesByAddressQuery{
SqlQuery{core},
notl,
}
err = Select(ctx, q, &tls)
So(err, ShouldBeNil)
t.Log(tls)
So(len(tls), ShouldEqual, 0)
})
}