commit inicial do projeto

This commit is contained in:
Júnior
2025-05-23 10:44:32 -03:00
commit 8f04473c0b
106 changed files with 5673 additions and 0 deletions

View 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")
}
}