mirror of
https://tvoygit.ru/Djam/abfapi.git
synced 2025-02-23 10:22:45 +00:00
add test
This commit is contained in:
parent
8a76ee743c
commit
f597ae3406
1 changed files with 35 additions and 0 deletions
35
main.go
Normal file
35
main.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"abfapi"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
logger := log.New(os.Stdout, "ABF: ", log.LstdFlags)
|
||||||
|
abfClient, err := abfapi.NewAbfJson("https://example.com/abf", "https://example.com/filestore", "username", "password", logger)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("Failed to create ABF client: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Пример вызова метода GetArchitectures
|
||||||
|
architectures, err := abfClient.GetArchitectures()
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("Failed to get architectures: %v", err)
|
||||||
|
}
|
||||||
|
logger.Printf("Architectures: %+v", architectures)
|
||||||
|
|
||||||
|
// Пример вызова метода UploadFile
|
||||||
|
shaHash, err := abfClient.UploadFile("testfile.txt", false)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("Failed to upload file: %v", err)
|
||||||
|
}
|
||||||
|
logger.Printf("Uploaded file SHA1: %s", shaHash)
|
||||||
|
|
||||||
|
// Пример вызова метода FetchFile
|
||||||
|
err = abfClient.FetchFile(shaHash, "downloaded_testfile.txt")
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("Failed to fetch file: %v", err)
|
||||||
|
}
|
||||||
|
logger.Printf("File fetched successfully")
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue