|
97 | 97 |
|
98 | 98 | echo "✅ Docker Compose test completed successfully" |
99 | 99 |
|
100 | | - - name: Test Docker image with mock data |
101 | | - run: | |
102 | | - echo "🔍 Testing Docker image with mock data..." |
103 | | -
|
104 | | - # Create a test container with mounted volumes |
105 | | - mkdir -p ./test-data/config ./test-data/logs ./test-data/copy ./test-data/backup ./test-data/TEMP |
106 | | - chmod -R 777 ./test-data/config ./test-data/logs ./test-data/copy ./test-data/backup ./test-data/TEMP |
107 | | -
|
108 | | - # Create a mock configuration file |
109 | | - cat > ./test-data/config/.config.cfg << 'EOF' |
110 | | - API_KEY="test_key" |
111 | | - API_SECRET="test_secret" |
112 | | - API_URL="https://api.trakt.tv" |
113 | | - ACCESS_TOKEN="test_token" |
114 | | - REFRESH_TOKEN="test_refresh" |
115 | | - REDIRECT_URI="urn:ietf:wg:oauth:2.0:oob" |
116 | | - USERNAME="test_user" |
117 | | - BACKUP_DIR="./backup" |
118 | | - DOSLOG="./logs" |
119 | | - DOSCOPY="./copy" |
120 | | - CONFIG_DIR="./config" |
121 | | - DATE="20250101_0000" |
122 | | - LOG="${DOSLOG}/Export_Trakt_4_Letterboxd_2025-01-01_00-00-00.log" |
123 | | - RED='\033[0;31m' |
124 | | - GREEN='\033[0;32m' |
125 | | - NC='\033[0m' |
126 | | - BOLD='\033[1m' |
127 | | - SAISPAS='\e[1;33;41m' |
128 | | - EOF |
129 | | -
|
130 | | - # Create example config file in the test directory |
131 | | - cp ./test-data/config/.config.cfg ./test-data/config/.config.cfg.example |
132 | | -
|
133 | | - # Create a simple test CSV file in copy directory |
134 | | - mkdir -p ./test-data/copy |
135 | | - echo "Title,Year,imdbID,Rating,WatchedDate" > ./test-data/copy/test_export.csv |
136 | | - echo "Test Movie,2024,tt0000001,8,2025-01-01" >> ./test-data/copy/test_export.csv |
137 | | -
|
138 | | - # Start the container with the mock data |
139 | | - docker run -d --name test-container-mock \ |
140 | | - -v $(pwd)/test-data/config:/app/config \ |
141 | | - -v $(pwd)/test-data/logs:/app/logs \ |
142 | | - -v $(pwd)/test-data/copy:/app/copy \ |
143 | | - -v $(pwd)/test-data/backup:/app/backup \ |
144 | | - -v $(pwd)/test-data/TEMP:/app/TEMP \ |
145 | | - trakt-export:test sleep 30 |
146 | | -
|
147 | | - # Wait for container to start |
148 | | - sleep 5 |
149 | | -
|
150 | | - # Verify container is running |
151 | | - docker ps | grep test-container-mock |
152 | | -
|
153 | | - # Verify container can see mounted volumes |
154 | | - docker exec test-container-mock bash -c "ls -la /app/config /app/logs /app/copy /app/backup /app/TEMP" |
155 | | -
|
156 | | - # Verify we can access script files |
157 | | - docker exec test-container-mock bash -c "ls -la /app/Export_Trakt_4_Letterboxd.sh /app/lib/*.sh" |
158 | | -
|
159 | | - # Verify scripts are executable |
160 | | - docker exec test-container-mock bash -c "test -x /app/Export_Trakt_4_Letterboxd.sh && echo 'Export script is executable'" |
161 | | - docker exec test-container-mock bash -c "find /app/lib -name '*.sh' -executable | wc -l" |
162 | | -
|
163 | | - # Create a test log file |
164 | | - docker exec test-container-mock bash -c "echo 'This is a test log' > /app/logs/test.log" |
165 | | -
|
166 | | - # Test if a CSV file can be read from copy directory |
167 | | - docker exec test-container-mock bash -c "cat /app/copy/test_export.csv" |
168 | | -
|
169 | | - # Clean up |
170 | | - docker stop test-container-mock |
171 | | - docker rm test-container-mock |
172 | | - rm -rf ./test-data |
173 | | -
|
174 | | - echo "✅ Docker image test with mock data completed successfully" |
175 | | -
|
176 | 100 | - name: Summary |
177 | 101 | run: | |
178 | 102 | echo "🎉 All Docker image tests passed successfully!" |
|
0 commit comments