commit inicial do projeto
This commit is contained in:
30
internal/oracle/store_test.go
Normal file
30
internal/oracle/store_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
package oracle
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestStore_SaveAndGet(t *testing.T) {
|
||||
s := NewStore(3)
|
||||
d := &OracleData{Key: "ETH-BRL", Value: 10000.0}
|
||||
|
||||
s.Save(d)
|
||||
|
||||
if got := s.Get("ETH-BRL"); got == nil || got.Value != 10000.0 {
|
||||
t.Error("falha ao buscar valor salvo")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStore_History(t *testing.T) {
|
||||
s := NewStore(2)
|
||||
|
||||
s.Save(&OracleData{Key: "ETH-BRL", Value: 1})
|
||||
s.Save(&OracleData{Key: "ETH-BRL", Value: 2})
|
||||
s.Save(&OracleData{Key: "ETH-BRL", Value: 3}) // deve descartar o primeiro
|
||||
|
||||
hist := s.History("ETH-BRL")
|
||||
if len(hist) != 2 {
|
||||
t.Errorf("esperado 2 entradas no histórico, obtido %d", len(hist))
|
||||
}
|
||||
if hist[0].Value != 2 || hist[1].Value != 3 {
|
||||
t.Error("histórico não está correto")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user