2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2016 Google LLC. All rights reserved.
|
2016-10-04 22:46:02 +00:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/file/file_util.h>
|
2016-10-04 22:46:02 +00:00
|
|
|
|
2023-10-13 19:42:47 +00:00
|
|
|
#include <absl/log/log.h>
|
2023-10-11 08:49:50 +00:00
|
|
|
#include <gtest/gtest.h>
|
2018-08-06 23:11:57 +00:00
|
|
|
|
2016-10-04 22:46:02 +00:00
|
|
|
namespace shaka {
|
|
|
|
|
2018-08-06 23:11:57 +00:00
|
|
|
TEST(FileUtilTest, TempFilePathInDesignatedDirectory) {
|
2016-10-04 22:46:02 +00:00
|
|
|
std::string temp_file_path;
|
|
|
|
EXPECT_TRUE(TempFilePath("test", &temp_file_path));
|
|
|
|
EXPECT_EQ(temp_file_path.find("test"), 0u);
|
2018-08-06 23:11:57 +00:00
|
|
|
LOG(INFO) << "temp file path: " << temp_file_path;
|
|
|
|
}
|
2016-10-04 22:46:02 +00:00
|
|
|
|
2018-08-06 23:11:57 +00:00
|
|
|
TEST(FileUtilTest, TempFilePathInSystemTempDirectory) {
|
|
|
|
std::string temp_file_path;
|
2016-10-04 22:46:02 +00:00
|
|
|
EXPECT_TRUE(TempFilePath("", &temp_file_path));
|
|
|
|
// temp_file_path should be created in a system specific temp directory.
|
2018-08-06 23:11:57 +00:00
|
|
|
LOG(INFO) << "temp file path: " << temp_file_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FileUtilTest, TempFilePathCalledTwice) {
|
|
|
|
const char kTempDir[] = "/test/";
|
|
|
|
std::string temp_file_path1;
|
|
|
|
std::string temp_file_path2;
|
|
|
|
ASSERT_TRUE(TempFilePath(kTempDir, &temp_file_path1));
|
|
|
|
ASSERT_TRUE(TempFilePath(kTempDir, &temp_file_path2));
|
|
|
|
ASSERT_NE(temp_file_path1, temp_file_path2);
|
|
|
|
LOG(INFO) << "temp file path1: " << temp_file_path1;
|
|
|
|
LOG(INFO) << "temp file path2: " << temp_file_path2;
|
2016-10-04 22:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace shaka
|