mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 15:10:05 +00:00 
			
		
		
		
	Warnings provider to access warnings text products
This commit is contained in:
		
							parent
							
								
									d5d9285736
								
							
						
					
					
						commit
						a2616b0ee0
					
				
					 7 changed files with 301 additions and 6 deletions
				
			
		
							
								
								
									
										58
									
								
								test/source/scwx/provider/warnings_provider.test.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								test/source/scwx/provider/warnings_provider.test.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,58 @@ | |||
| #include <scwx/provider/warnings_provider.hpp> | ||||
| 
 | ||||
| #include <gtest/gtest.h> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace provider | ||||
| { | ||||
| 
 | ||||
| static const std::string& kDefaultUrl {"https://warnings.allisonhouse.com"}; | ||||
| static const std::string& kAlternateUrl {"http://warnings.cod.edu"}; | ||||
| 
 | ||||
| class WarningsProviderTest : public testing::TestWithParam<std::string> | ||||
| { | ||||
| }; | ||||
| TEST_P(WarningsProviderTest, ListFiles) | ||||
| { | ||||
|    WarningsProvider provider(GetParam()); | ||||
| 
 | ||||
|    auto [newObjects, totalObjects] = provider.ListFiles(); | ||||
| 
 | ||||
|    EXPECT_GT(newObjects, 0); | ||||
|    EXPECT_GT(totalObjects, 0); | ||||
|    EXPECT_EQ(newObjects, totalObjects); | ||||
| } | ||||
| 
 | ||||
| TEST_P(WarningsProviderTest, LoadUpdatedFiles) | ||||
| { | ||||
|    WarningsProvider provider(GetParam()); | ||||
| 
 | ||||
|    auto [newObjects, totalObjects] = provider.ListFiles(); | ||||
|    auto updatedFiles               = provider.LoadUpdatedFiles(); | ||||
| 
 | ||||
|    EXPECT_GT(newObjects, 0); | ||||
|    EXPECT_GT(totalObjects, 0); | ||||
|    EXPECT_EQ(newObjects, totalObjects); | ||||
|    EXPECT_EQ(updatedFiles.size(), newObjects); | ||||
| 
 | ||||
|    auto [newObjects2, totalObjects2] = provider.ListFiles(); | ||||
|    auto updatedFiles2                = provider.LoadUpdatedFiles(); | ||||
| 
 | ||||
|    // There should be no more than 2 updated warnings files since the last query
 | ||||
|    // (assumption that the previous newest file was updated, and a new file was
 | ||||
|    // created on the hour)
 | ||||
|    EXPECT_LE(newObjects2, 2); | ||||
|    EXPECT_EQ(updatedFiles2.size(), newObjects2); | ||||
| 
 | ||||
|    // The total number of objects may have changed, since the oldest file could
 | ||||
|    // have dropped off the list
 | ||||
|    EXPECT_GT(totalObjects2, 0); | ||||
| } | ||||
| 
 | ||||
| INSTANTIATE_TEST_SUITE_P(WarningsProvider, | ||||
|                          WarningsProviderTest, | ||||
|                          testing::Values(kDefaultUrl, kAlternateUrl)); | ||||
| 
 | ||||
| } // namespace provider
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat