Skip to content
Snippets Groups Projects
Commit 062bbb97 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

fts returns NotFound instead of BadRequest

parent caa3f62a
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,27 @@ func (suite *StreamsTestSuite) TestStreamsUsesCache() { ...@@ -54,6 +54,27 @@ func (suite *StreamsTestSuite) TestStreamsUsesCache() {
suite.Equal(int64(1), rec.Streams[0].TimestampLast) suite.Equal(int64(1), rec.Streams[0].TimestampLast)
} }
func (suite *StreamsTestSuite) TestStreamsCacheexpires() {
db.settings.UpdateStreamCachePeriodMs = 100
var res1 StreamsRecord
go func() {
db.insertRecord(dbname, collection, &rec1)
streams.getStreams(&db, Request{DbName: dbname, ExtraParam: ""})
db.insertRecord(dbname, collection, &rec_finished)
res1,_ = streams.getStreams(&db, Request{DbName: dbname, ExtraParam: ""})
}()
db.insertRecord(dbname, collection+"1", &rec1_later)
res2,_ := streams.getStreams(&db, Request{DbName: dbname, ExtraParam: ""})
db.insertRecord(dbname, collection+"1", &rec_finished)
time.Sleep(time.Second)
res3, err := streams.getStreams(&db, Request{DbName: dbname, ExtraParam: ""})
suite.Nil(err)
suite.Equal(true, res3.Streams[0].Finished)
fmt.Println(res1,res2)
// suite.Equal(true, rec.Streams[1].Finished)
}
func (suite *StreamsTestSuite) TestStreamsGetFinishedInfo() { func (suite *StreamsTestSuite) TestStreamsGetFinishedInfo() {
db.settings.UpdateStreamCachePeriodMs = 1000 db.settings.UpdateStreamCachePeriodMs = 1000
db.insertRecord(dbname, collection, &rec1) db.insertRecord(dbname, collection, &rec1)
......
...@@ -417,7 +417,7 @@ Error StreamInfoFromDbResponse(const std::string &last_record_str, ...@@ -417,7 +417,7 @@ Error StreamInfoFromDbResponse(const std::string &last_record_str,
return err; return err;
} }
return UpdateStreamInfoFromEarliestRecord(last_record_str,info); return UpdateStreamInfoFromEarliestRecord(earliest_record_str,info);
} }
......
...@@ -21,7 +21,7 @@ type fileTransferRequest struct { ...@@ -21,7 +21,7 @@ type fileTransferRequest struct {
func Exists(name string) bool { func Exists(name string) bool {
fi, err := os.Stat(name) fi, err := os.Stat(name)
return !os.IsNotExist(err) && !fi.IsDir() return err==nil && !fi.IsDir()
} }
...@@ -42,7 +42,7 @@ func checkFileExists(r *http.Request,name string) (int,error) { ...@@ -42,7 +42,7 @@ func checkFileExists(r *http.Request,name string) (int,error) {
if !Exists(name) { if !Exists(name) {
err_txt := "file "+name+" does not exist" err_txt := "file "+name+" does not exist"
log.Error("cannot transfer file: "+err_txt) log.Error("cannot transfer file: "+err_txt)
return http.StatusBadRequest,errors.New(err_txt) return http.StatusNotFound,errors.New(err_txt)
} }
return http.StatusOK,nil return http.StatusOK,nil
......
...@@ -60,7 +60,7 @@ var transferFileTests = [] struct { ...@@ -60,7 +60,7 @@ var transferFileTests = [] struct {
message string message string
}{ }{
{"folder","exists", prepareToken("folder"),http.StatusOK,"file transferred"}, {"folder","exists", prepareToken("folder"),http.StatusOK,"file transferred"},
{"folder","not_exists", prepareToken("folder"),http.StatusBadRequest,"file not exists"}, {"folder","not_exists", prepareToken("folder"),http.StatusNotFound,"file not exists"},
{"wrong_folder","p07", prepareToken("folder"),http.StatusUnauthorized,"wrong folder"}, {"wrong_folder","p07", prepareToken("folder"),http.StatusUnauthorized,"wrong folder"},
{"folder","p07", "wrong token",http.StatusUnauthorized,"wrong token"}, {"folder","p07", "wrong token",http.StatusUnauthorized,"wrong token"},
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment