TODO: extractor openrec
This commit is contained in:
5
extractor/openrec/main.go
Normal file
5
extractor/openrec/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
37
extractor/openrec/openrec_test.go
Normal file
37
extractor/openrec/openrec_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"intimate"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func TestExtractor(t *testing.T) {
|
||||
store := intimate.NewSourceStore("source_openrec")
|
||||
source, err := store.Pop("openrec_user", 100)
|
||||
if source != nil {
|
||||
defer store.Restore(source)
|
||||
}
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sdata := source.GetExt().([]byte)
|
||||
|
||||
if gjson.ValidBytes(sdata) {
|
||||
result := gjson.ParseBytes(sdata)
|
||||
m := result.Map()
|
||||
for key := range m {
|
||||
t.Error(key)
|
||||
f, err := os.OpenFile("./openrec_"+key+".html", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.WriteString(m[key].String())
|
||||
}
|
||||
} else {
|
||||
t.Error("data is not json:\n", string(sdata))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user